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


using namespace std;

int inf = 1e9+7;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> a(n+1);
	bool rosnacy = 1;
	vector<int> prefmin(n+1);
	vector<int> sufmax(n+2);
	prefmin[0] = inf;
	sufmax[n+1] = -inf;
	int mini = inf, maxi = -inf;
	for (int i = 1; i <= n; i++){
		cin >> a[i];
		if (!(a[i] > a[i-1])) rosnacy = 0;
		prefmin[i] = min(a[i], prefmin[i-1]);
		maxi = max(maxi, a[i]);
		mini = min(mini, a[i]);
	}
	for (int i = n; i >= 1; i--) sufmax[i] = max(a[i], sufmax[i+1]);
	if (rosnacy){
		cout << "NIE";
		return 0;
	}
	if (k == 2){
		for (int i = 1; i <= n-1; i++){
			if (prefmin[i] >= sufmax[i+1]){
				cout << "TAK\n";
				cout << i;	
				return 0;
			}
		}
		cout << "NIE";
		return 0;
	}
	if (k == 3){
		for (int i = 2; i <= n-1; i++){
			if (a[i] == mini || a[i] == maxi){
				cout << "TAK\n";
				cout << i-1 << " " << i;
				return 0;
			}
		}
		cout << "NIE";
		return 0;
	}
	vector<int> przerwy(n+2);
	int ile = 3;
	for (int i = 2; i <= n; i++){
		if (a[i] <= a[i-1]){
			przerwy[i-1] = 1;
			przerwy[i] = 1;
			przerwy[i+1] = 1;
			if (!(i-2) || (i+1)==(n+1)){
				ile--;
				//cout << i << "lol\n";
			}
		}
	}
	cout << "TAK\n";
	//cout << ile << " ";
	for (int i = 2; i <= n; i++){
		if (przerwy[i]) cout << i-1 << " ";
		else if (ile != k-1){
			cout << i-1 << " ";
			ile++;
		}
	}
	
	
	return 0;



}