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
#include <bits/stdc++.h>
#define iamspeed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;

int n, k, kw4 = 1, kwleft, kwright, mini[500005], maxi[500005], t[500005];

int main(){
	iamspeed;
	cin >> n >> k;
	for(int i = 1 ; i <= n ; i++){
		cin >> t[i];
		if(i >= 2 && t[i] <= t[i - 1] && kw4){ 
			kw4 = 0;
			kwleft = i - 1;
			kwright = i;
		}
	}
	if(k >= 4){
		if(!kw4){
			cout << "TAK" << endl;
			for(int i = max(1, kwright - k + 1 + (kwright != n)) ; k > 1 ; k--, i++)
				cout << i << " ";
			cout << endl;
			return 0;
		}
	}
	else if(k == 3){
		for(int i = 2 ; i < n ; i++){
			if(t[i] <= t[1]){
				cout << "TAK" << endl << i - 1 << " " << i << endl;
				return 0;
			}
		}
		for(int i = n - 1 ; i > 1 ; i--){
			if(t[i] >= t[n]){
				cout << "TAK" << endl << i - 1 << " " << i << endl;
				return 0;
			}
		}
	}
	else{
		mini[1] = t[1]; maxi[n] = t[n];
		for(int i = 2 ; i <= n ; i++)
			mini[i] = min(mini[i - 1], t[i]);
		for(int i = n - 1; i > 0 ; i--)
			maxi[i] = max(maxi[i + 1], t[i]);
		for(int i = 1 ; i < n ; i++){
			if(mini[i] >= maxi[i + 1]){
				cout << "TAK" << endl << i << endl;
				return 0;
			}
		}
	}
	cout << "NIE" << endl;
}