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
#include <cstdio>
#include <algorithm>

using namespace std;

int A[500005];
int MXE[500005];

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    for (int i=0; i<n; i++) scanf("%d", A+i);
    if (k == 2) {
        MXE[n-1] = A[n-1];
        for (int i=n-2; i>=0; i--) {
            MXE[i] = max(A[i], MXE[i+1]);
        }
        int mn = 1000000009;
        for (int i=0; i<n-1; i++) {
            mn = min(A[i], mn);
            if (mn >= MXE[i+1]) {
                printf("TAK\n%d\n", i+1);
                return 0;
            }
        }
        printf("NIE\n");
        return 0;
    } else if (k == 3) {
        int mn = 1000000009;
        for (int i=0; i<n-2; i++) {
            mn = min(A[i], mn);
            if (mn >= A[i+1]) {
                printf("TAK\n%d %d\n", i+1, i+2);
                return 0;
            }
        }
        int mx = 0;
        for (int i=n-1; i>=2; i--) {
            mx = max(A[i], mx);
            if (mx <= A[i-1]) {
                printf("TAK\n%d %d\n", i-1, i);
                return 0;
            }
        }
        printf("NIE\n");
        return 0;
    } else {
        int p = -1;
        for (int i=1; i<n; i++) {
            if (A[i-1] >= A[i]) {
                p = i-1;
                break;
            }
        }
        if (p == -1) {
            printf("NIE\n");
            return 0;
        }
        printf("TAK\n");
        for (int i=0; i<min(k-4, p-1); i++) printf("%d ", i+1);
        printf("%d %d %d ", p, p+1, p+2);
        for (int i=0; i<k-3-p; i++) printf("%d ", p+i+3);
    }
    return 0;
}