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
78
79
80
81
82
#include <bits/stdc++.h>

using namespace std;

vector<int> incomes;
int downPos = -1, minPos = 1, maxPos = 1;
int n, k;

void nCase() {
    cout << "TAK" << endl;
    int first = min(downPos, n - 1);
    first = max(first - k + 2, 1);
    for (int i = first; i < first + k - 1; ++i) {
        cout << i << ' ';
    }
}

void threeCase() {
    if (minPos != 1) {
        cout << "TAK" << endl;
        int first = min(minPos, n - 1) - 1;
        cout << first << ' ' << first + 1 << endl;
        return;
    }
    if (maxPos != n) {
        cout << "TAK" << endl;
        int first = max(maxPos, 2) - 1;
        cout << first << ' ' << first + 1 << endl;
        return;
    }
    cout << "NIE" << endl;
}

void twoCase() {
    vector<int> mins, maxs;
    mins.resize(n + 1);
    maxs.resize(n + 1);
    mins[1] = incomes[1];
    for (int i = 2; i <= n; ++i) {
        mins[i] = min(mins[i - 1], incomes[i]);
    }
    maxs[n] = incomes[n];
    for (int i = n - 1; i >= 1; --i) {
        maxs[i] = max(maxs[i + 1], incomes[i]);
    }
    for (int i = 1; i <= n - 1; ++i) {
        if (mins[i] >= maxs[i + 1]) {
            cout << "TAK" << endl;
            cout << i;
            return;
        }
    }
    cout << "NIE" << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> k;
    incomes.resize(n + 1);
    cin >> incomes[1];
    for (int i = 2; i <= n; ++i) {
        cin >> incomes[i];
        if (incomes[i - 1] >= incomes[i]) downPos = i;
        if (incomes[minPos] >= incomes[i]) minPos = i;
        if (incomes[maxPos] < incomes[i]) maxPos = i;
    }
    if (downPos == -1) {
        cout << "NIE" << endl;
        return 0;
    }
    switch (k) {
        case 2:
            twoCase();
            break;
        case 3:
            threeCase();
            break;
        default:
            nCase();
    }
}