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
 92
 93
 94
 95
 96
 97
 98
 99
100
101
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <set>
#include <vector>

constexpr int N = 5e5 + 1;
int t[N];
int n, k;

void solve_2() {
    std::multiset<int> R;
    int L = 2e9;
    int pos = 1;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &t[i]);
        R.insert(t[i]);
    }
    bool result = false;
    for (int i = 1; i < n; i++) {
        L = std::min(L, t[i]);
        auto itr = R.find(t[i]);
        R.erase(itr);
        if (L >= *R.rbegin()) {
            result = true;
            pos = i;
            break;
        }
    }
    printf(result ? "TAK" : "NIE");
    if (result) {
        printf("\n%d\n", pos);
    }
    exit(0);
}

void solve_3() {
    bool result = false;
    int pos1 = 1, pos2 = 1;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &t[i]);
    }
    for (int i = 2; i < n; i++) {
        if (t[i] <= t[1]) {
            result = true;
            pos1 = i-1;
            pos2 = i;
            break;
        }
    }
    for (int i = n-1; i >= 2; i--) {
        if (t[i] >= t[n]) {
            result = true;
            pos1 = i-1;
            pos2 = i;
            break;
        }
    }
    printf((result) ? "TAK" : "NIE");
    if (result) {
        printf("\n%d %d\n", pos1, pos2);
    }
    exit(0);
}

int main() {
    scanf("%d%d", &n, &k);
    if (k == 2) solve_2();
    if (k == 3) solve_3();
    bool result = false;
    int pos1 =-1, pos2=-1, pos3=-1;
    std::vector<int> pos;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &t[i]);
    }
    for (int i = 2; i <= n; i++) {
        if (t[i-1] >= t[i]) {
            result = true;
            if (i != n) {
                pos.push_back(i); pos1 = i;
            }
            pos.push_back(i-1); pos2 = i-1;
            if (i != 2) {
                pos.push_back(i-2); pos3 = i-2;
            }
            break;
        }
    }
    for (int i = 1; i < n; i++) {
        if (int(pos.size()) < k-1 && i != pos1 && i != pos2 && i != pos3) {
            pos.push_back(i);
        }
    }
    sort(pos.begin(), pos.end());
    printf(result ? "TAK\n" : "NIE\n");
    if (result) {
        for (int i : pos) {
            printf("%d ", i);
        }
    }
}