1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cmath>
using namespace std;

const int m = 500000;
struct days {
    int pref;
    int suff;
};
int n_day, n_range, day[m];
days min_max[m];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n_day >> n_range;
    for (int i = 0; i < n_day; i++)
        cin >> day[i];
    if (n_range > 3) {
        int division = -1;
        for (int i = 0; i < n_day - 1; i++) {
            if (day[i] >= day[i + 1]) {
                division = i;
                break;
            }
        }
        if (division < 0) {
            cout << "NIE";
            return 0;
        }
        cout << "TAK\n";
        if (division == n_day - 1) {
            for (int i = 1; i < n_range - 2; i++)
                cout << i << ' ';
            cout << division << ' ' << division + 1;
        }
        if (division < n_range - 2)
            for (int i = 1; i < n_range; i++)
                cout << i << ' ';
        else {
            for (int i = 1; i < n_range - 3; i++)
                cout << i << ' ';
            cout << division << ' ' << division + 1 << ' ' << division + 2;
        }
        return 0;
    }
    min_max[0].pref = day[0];
    for (int i = 1; i < n_day; i++)
        min_max[i].pref = min(min_max[i - 1].pref, day[i]);
    min_max[n_day - 1].suff = day[n_day - 1];
    for (int i = n_day-2; i >=0; i--)
        min_max[i].suff = max(min_max[i + 1].suff, day[i]);
    if (n_range == 2) {
        for (int i = 0; i < n_day - 1; i++)
            if (min_max[i].pref >= min_max[i + 1].suff) {
                cout << "TAK\n" << i + 1;
                return 0;
            }
    }
    else {
        for (int i=1;i<n_day-1;i++)
            if (min_max[i - 1].pref >= day[i] || day[i] >= min_max[i + 1].suff) {
                cout << "TAK\n" << i << ' ' << i + 1;
                return 0;
            }
    }
    cout << "NIE";
}