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
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pb push_back
#define FOR(i,n) for(int i=0; i<n; i++)
#define watch(x) cout << (#x) << " == " << (x) << endl
typedef long long ll;
typedef long double ld;
using namespace std;
const ll N = 5e5;
int tab[N+5];
int mmax[N+5];

int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);

int n,k;
cin>>n>>k;

for (int i=1; i<=n; i++){
  cin>>tab[i];
}

if (k >= 4){
  int x = -1;
  for (int i=1; i<=n-1; i++){
    if (tab[i] >= tab[i+1]){
      x=i;
      break;
    }
  }

  if (x == -1){
    cout<<"NIE\n";
  } else {
    cout<<"TAK\n";
    if (k >= x+2){
      FOR(i,k-1){
        cout<<i+1<<" ";
      }
    } else {
      FOR(i,k-4){
        cout<<i+1<<" ";
      }
      cout<<x-1<<" "<<x<<" "<<x+1;
    }
  }
} else if (k == 3){
  for (int i=2; i<=n-1; i++){
    if (tab[1] >= tab[i]){
      cout<<"TAK\n";
      cout<<i-1<<" "<<i;
      return 0;
    }
  }

  for (int i=n-1; i>=1; i--){
    if (tab[i] >= tab[n]){
      cout<<"TAK\n";
      cout<<i-1<<" "<<i;
      return 0;
    }
  }
     cout<<"NIE";
} else { // n == 2
    mmax[n+1]=0;
    for (int i=n; i>=1; i--){
      mmax[i] = max(mmax[i+1], tab[i]);
    }
    int mmin=tab[1];
    for (int i=1; i<=n-1; i++){
      mmin = min(mmin, tab[i]);
      if (mmin >= mmax[i+1]){
        cout<<"TAK\n";
        cout<<i-1<<" "<<i;
        return 0;
      }
    }
    cout<<"NIE\n";
  }

return 0;
}