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
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

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

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

	pair<int, int> arr[n];
	vector<int> vec;
	for(auto& i : arr) {
		static int t = 0;
		cin >> i.first;
		i.second = ++t;
	}

	sort(arr, arr+n, [](const auto& a, const auto& b) {
		return a.first == b.first ? a.second < b.second : a.first > b.first;
	});

	for(auto i = arr+1; i < arr+n && k > 0; ++i) {
		if(abs(i->second - i[-1].second) <= 1)
			k--;
		else
			k -= 2;
		vec.push_back((i-1)->second);
	}
	sort(vec.begin(), vec.end());
	if(vec.back() == n) {
		--vec.back();
		for(auto i = vec.rbegin()+1; i < vec.rend(); ++i)
			if(*prev(i) == *i)
				--*i;
		if(vec.front() == 0) {
			cout << "NIE";
			return 0;
		}
	}


	vector<int> tmp;
	tmp.reserve(vec.size());

	for(const auto& i : vec) {
		static int t = 0;
		tmp.push_back(*min_element(vec.begin()+t, vec.begin()+i));
		t = i;
	}

	for(auto i = tmp.cbegin()+1; i < tmp.cend(); ++i) {
		if(*prev(i) >= *i) {
			cout << "TAK\n";
			for(const auto& i : vec)
				cout << i << ' ';
			return 0;
		}
	}

	cout << "NIE";
}