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
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

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

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

	vector<int> V(n);
	for (auto& v : V)
		cin >> v;

	bool is_ok = false;
	for (int i = 0; i < n - 1; i++) 
		if (V[i] >= V[i + 1]) 
			is_ok = true;
	if (!is_ok) {
		cout << "NIE";
		exit(0);
	}

	if (k == 2) {
		vector<int> MinP(n + 1, INT32_MAX), MaxS(n + 1);
		for (int i = 0; i < n; i++)
			MinP[i + 1] = min(MinP[i], V[i]);
		for (int i = n - 1; i >= 0; i--)
			MaxS[i] = max(MaxS[i + 1], V[i]);

		for (int i = 0; i < n - 1; i++) {
			if (MinP[i + 1] >= MaxS[i + 1]) {
				cout << "TAK\n" << i + 1;
				exit(0);
			}
		}

		cout << "NIE";
	}
	else if (k == 3) {
		int m = *min_element(V.begin(), V.end());
		int M = *max_element(V.begin(), V.end());

		if (V.front() == M)
			cout << "TAK\n1 2";
		else if (V.back() == m)
			cout << "TAK\n1" << n - 1;
		else {
			for (int i = 1; i < n - 1; i++) {
				if (V[i] == m || V[i] == M) {
					cout << "TAK\n" << i << ' ' << i + 1;
					exit(0);
				}
			}
			cout << "NIE";
		}
	}
	else {
		set<int> S;
		for (int i = 0; i < n - 1; i++) {
			if (V[i] >= V[i + 1]) {
				if (i != 0) S.insert(i - 1);
				S.insert(i);
				if (i != n - 2) S.insert(i + 1);
				break;
			}
		}

		if (S.size()) {
			cout << "TAK\n";
			for (int i = 0; i < n; i++) {
				if (S.size() == k - 1)
					break;
				S.insert(i);
			}

			for (auto& s : S)
				cout << s + 1 << ' ';
		}
		else
			cout << "NIE";
	}
}