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
#include <iostream>
#include <set>
#include <algorithm>

const int MAX = 500005;
int A[MAX];
int n,k;

void Print(std::set<int> I) {
    I.erase(0);
    I.erase(n);
    int v = 0;
    while (I.size() < k-1) I.insert(++v);
    std::cout << "TAK" << std::endl;
    for (int i : I) std::cout << i << " ";
    std::cout << std::endl;
}

int main () {
    std::ios_base::sync_with_stdio(0);
    std::cin >> n >> k;
    for (int i=0;i<n;++i) std::cin >> A[i];

    if (k == 2) {
        std::multiset<int> L(A,A+1);
        std::multiset<int> R(A+1,A+n);
        int i=1;
        int j=-1;
        while (i<n && j==-1) {
            if (*L.begin() >= *R.rbegin()) j = i;
            L.insert(A[i]);
            R.erase(R.find(A[i]));
            ++i;
        }
        if (j == -1) std::cout << "NIE" << std::endl;
        else Print({j});
    } else if (k == 3) {
        auto min = std::min_element(A+1, A+n);
        auto max = std::max_element(A, A+n-1);
        int j = -1;
        if (*min <= A[0]) j = std::distance(A, min);
        else if (*max >= A[n-1]) j = std::distance(A, max);
        if (j == -1) std::cout << "NIE" << std::endl;
        else Print({j,j+1});
    } else if (k >= 4) {
        int j = -1;
        for (int i=1;i<n && j==-1;++i)
            if (A[i-1] >= A[i])
                j=i;
        if (j == -1) std::cout << "NIE" << std::endl;
        else Print({j-1,j,j+1});
    } else {
        std::cerr << "You picked the wrong number, FOOL!" << std::endl;
    }
    return 0;
}