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
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include <bits/stdc++.h>
using namespace std;
#pragma GCC maksuje_zadania_na_essie("pot200");

bool is_increasing(const vector<int> &arr) {
	for(int i = 1; i < arr.size(); i++) {
		if(arr[i] <= arr[i-1]) return false;
	}
	return true;
}

void finish_yep(const vector<int> &indeces) {
	cout << "TAK\n";
	#ifndef NO_INDECES
		for(int i : indeces) {
			cout << i << ' ';
		}
		cout << '\n';
	#endif
	exit(0);
}

void finish_nope() {
	cout << "NIE\n";
	exit(0);
}

void solve_K2(int n, const vector<int> &inp) {

	vector<int> min_pref(n); min_pref[0] = inp[0];
	vector<int> max_suff(n); max_suff[n-1] = inp[n-1];

	for(int i = 1; i < n; i++) {
		min_pref[i] = min(min_pref[i-1], inp[i]);
		max_suff[n-i-1] = max(max_suff[n-i], inp[n-i-1]);
	}

	for(int i = 1; i < n; i++) {
		if(min_pref[i-1] >= max_suff[i]) {
			finish_yep({ i });
		}
	}

	finish_nope();

}

void solve_K3(int n, const vector<int> &inp) {

	int min_pref = inp[0];
	int max_suff = inp[n-1];

	for(int i = 1; i < n-1; i++) {

		if(min_pref >= inp[i]) finish_yep({ i, i+1 });
		if(max_suff <= inp[n-i-1]) finish_yep({ n-i-1,n-i });

		min_pref = min(min_pref, inp[i]);
		max_suff = max(max_suff, inp[n-i-1]);

	}

	finish_nope();

}

void solve_KG3(int n, int k, const vector<int> &inp) {

	vector<int> used(n+2);
	vector<int> indeces;

	for(int i = 1; i < n-1; i++) {
		if(inp[i] >= inp[i+1]) {
			used[i] = used[i+1] = used[i+2] = 1;
			k -= 3 - (i == 0 || i+2 == n);
			break;
		}
	}

	for(int i = 1; i < n; i++) {

		if(!used[i] && k > 1)
			used[i] = 1, k--;

		if(used[i]) 
			indeces.push_back(i);

	}

	finish_yep(indeces);
	
}

int main() {

    cin.tie(0)->sync_with_stdio(false);
    int n, k; cin >> n >> k;

	vector<int> inp(n);

	for(int i = 0; i < n; i++) 
		cin >> inp[i];

	if(is_increasing(inp)) 
		finish_nope();

	if(k == 2) 
		solve_K2(n, inp);
	else if(k == 3) 
		solve_K3(n, inp);
	else 
		solve_KG3(n, k, inp);

}