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
83
84
85
86
87
88
89
90
91
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a;
    a.resize(n);
    bool inc = true;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if ((i > 0) && (a[i] <= a[i - 1])) {
            inc = false;
        }
    }
    if (inc) {
        cout << "NIE\n";
        return 0;
    }
    if (n == 2) {
        cout << "TAK\n1\n";
        return 0;
    }
    else if (k == 2) {
        vector<int> mi, ma;
        mi.resize(n);
        ma.resize(n);
        mi[0] = a[0];
        ma[n - 1] = a[n - 1];
        for (int i = 1; i < n; i++) {
            mi[i] = min(mi[i - 1], a[i]);
        }
        for (int i = n - 2; i >= 0; i--) {
            ma[i] = max(ma[i + 1], a[i]);
        }
        for (int i = 0; i < n - 1; i++) {
            if (mi[i] >= ma[i + 1]) {
                cout << "TAK\n" << 1 + i << "\n";
                return 0;
            }
        }
        cout << "NIE\n";
        return 0;
    }
    else if (k == 3) {
        int pos1 = 0, pos2 = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] > a[pos1]) {
                pos1 = i;
            }
            if (a[i] <= a[pos2]) {
                pos2 = i;
            }
        }
        if (pos1 < n - 1) {
            if (pos1 == 0) {
                cout << "TAK\n" << 1 + pos1 << " " << 1 + pos1 + 1 << "\n";
            }
            else {
                cout << "TAK\n" << 1 + pos1 - 1 << " " << 1 + pos1 << "\n";
            }
            return 0;
        }
        if (pos2 > 0) {
            cout << "TAK\n" << 1 + pos2 - 1 << " " << 1 + pos2 << "\n";
            return 0;
        }
        cout << "NIE\n";
        return 0;
    }
    else {
        for (int i = 0; i < n - 1; i++) {
            if (a[i + 1] <= a[i]) {
                int b = max(0, i - (k - 3));
                if (i == 0) {
                    b = 0;
                }
                cout << "TAK\n";
                for (int j = 0; j < k - 1; j++) {
                    cout << 1 + b + j << " ";
                }
                return 0;
            }
        }
        cout << "NIE\n";
        return 0;
    }
}