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
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k;
	cin >> n >> k;
	vector <int> v(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	// algorytm dla k == 2
	// if (k == 2) nie działa
	// algorytm dla k == 3
	// if (k == 3) nie działa
	// algorytm dla k == 4
	// nie działa
	

	auto k2 = [&]() {
		vector <int> minl(n);
		vector <int> maxr(n);
		for (int i = 0; i < n; i++) {
			if (i == 0)
				minl[i] = v[i];
			else
				minl[i] = min(minl[i-1], v[i]);
		}
		for (int i = n-1; i >= 0; i--) {
			if (i == n-1)
				maxr[i] = v[i];
			else
				maxr[i] = max(maxr[i+1], v[i]);
		}
		for (int i = 1; i < n; i++) {
			if (minl[i-1] >= maxr[i]) {
				vector <bool> res(n+1);
				res[i] = 1;
				int ile = 1;
				cout << "TAK\n";
				for (int j = 1; j < n; j++)
					if (ile != k-1 && !res[j])
						res[j] = 1, ile++;
				for (int j = 1; j < n; j++)
					if (res[j])	
						cout << j << " ";
				exit(0);
			}
		}
	};
	k2();
	if (k == 2) {
		cout << "NIE\n";
		return 0;
	}


	auto k3 = [&]() { 
		int maxx = 0, minn = INT_MAX;
		for (int i = 0; i < n; i++) {
			maxx = max(maxx, v[i]);
			minn = min(minn, v[i]);
		}
		for (int i = 1; i < n-1; i++) {
			if (v[i] == maxx || v[i] == minn) {
				vector <int> res(n+1);
				res[i] = res[i+1] = 1;
				int ile = 2;
				cout << "TAK\n";
				for (int j = 1; j < n; j++)
					if (ile != k-1 && !res[j])
						res[j] = 1, ile++;
				for (int j = 1; j < n; j++)
					if (res[j])
						cout << j << " ";
				exit(0);
			}
		}
	};
	k3();
	if (k == 3) {
		cout << "NIE\n";
		return 0;
	}


	auto k4 = [&]() {
		for (int i = 1; i < n; i++) {
			if (v[i] <= v[i-1]) {
				vector <int> res(n+1);
				res[i-1] = res[i] = res[i+1] = 1;
				int ile = 3;
				cout << "TAK\n";
				for (int j = 1; j < n; j++)
					if (ile != k-1 && !res[j])
						res[j] = 1, ile++;
				for (int j = 1; j < n; j++)
					if (res[j])
						cout << j << " ";
				exit(0);
			}
		}
	};
	k4();
	cout << "NIE\n";
	return 0;

}