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
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;

  vector<int> v;

  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    v.push_back(a);
  }

  if (k == 2 || k == 3) {
    int Min = v[0];
    vector<int> min_vec = {Min};
    for (int i = 1; i < n - 1; i++) {
      Min = min(Min, v[i]);
      min_vec.push_back(Min);
    }

    int Max = v[n - 1];
    vector<int> max_vec = {Max};
    for (int i = n - 2; i >= 1; i--) {
      Max = max(Max, v[i]);
      max_vec.push_back(Max);
    }

    if (k == 2) {
      for (int i = 0; i < n - 1; i++) {
        if (min_vec[i] >= max_vec[n - 2 - i]) {
          cout << "TAK\n";
          cout << i + 1;
          return 0;
        }
      }

      cout << "NIE";
    } else {
      for (int i = 0; i < n - 2; i++) {
        if (min_vec[i] >= v[i + 1] || v[i + 1] >= max_vec[n - 3 - i]) {
          cout << "TAK\n";
          cout << i + 1 << " " << i + 2;
          return 0;
        }
      }

      cout << "NIE";
    }

  } else {
    int prev = v[0];
    int cur;
    for (int i = 1; i < n; i++) {
      cur = v[i];

      if (cur <= prev) {  // TAK
        cout << "TAK\n";

        int start = min(n + 1 - k, max(i - 1, 1));
        for (int i = 0; i < k - 1; i++)
          cout << start++ << " ";
        return 0;
      }

      prev = cur;
    }

    cout << "NIE";
  }

  return 0;
}