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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include <bits/stdc++.h>

//#define DEBUG
//#define VALDEBUG

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> in(n);
	for (int i = 0; i < n; i++) cin >> in[i];
	if (k == 2)
	{
		vector<int> prefmin(n);
		vector<int> suffmax(n);
		prefmin[0] = in[0];
		suffmax[n - 1] = in[n - 1];
		for (int i = 1; i < n; i++) prefmin[i] = min(prefmin[i-1], in[i]);
		for (int i = n - 2; i >= 0; i--) suffmax[i] = max(suffmax[i + 1], in[i]);
		for (int i = 0; i < n - 1; i++)
		{
			if (prefmin[i] >= suffmax[i + 1])
			{
				cout << "TAK\n";
				#ifndef DEBUG
				cout << i + 1 << '\n';
				#endif
				return 0;
			}
		}
		cout << "NIE\n";
		return 0;
	}
	else if (k == 3)
	{
		int minval = 1e9 + 9;
		int maxval = -1;
		int maxpos = -1;
		int minpos = -1;
		for (int i = 0; i < n; i++)
		{
			if (in[i] <= minval)
			{
				minval = in[i];
				minpos = i;
			}
		}
		for (int i = n - 1; i >= 0; i--)
		{
			if (in[i] >= maxval)
			{
				maxval = in[i];
				maxpos = i;
			}
		}
		if (minval == maxval || (minpos == 0 && maxpos == n - 1))
		{
			cout << "NIE\n";
			return 0;
		}
		cout << "TAK\n";
		#ifdef VALDEBUG
		cout << n << " " << k << '\n';
		for (int i = 0; i < n; i++) cout << in[i] << " ";
		cout << '\n';
		#endif
		#ifndef DEBUG
		if (maxpos == n - 1)
		{
			cout << minpos << " " << minpos + 1 << '\n';
		}
		else
		{
			if (maxpos == 0)
			{
				cout << "1 2\n";
			}
			else
			{
				cout << maxpos << " " << maxpos + 1 << '\n';
			}
		}
		#endif
	}
	else
	{
		int ans = -1;
		for (int i = 1; i < n; i++)
		{
			if (in[i] <= in[i - 1])
			{
				ans = i + 1;
				break;
			}
		}
		if (ans == -1)
		{
			cout << "NIE\n";
			return 0;
		}
		cout << "TAK\n";
		#ifdef VALDEBUG
		cout << n << " " << k << '\n';
		for (int i = 0; i < n; i++) cout << in[i] << " ";
		cout << '\n';
		#endif
		#ifndef DEBUG
		if (ans == 2)
		{
			cout << "1 2 ";
			k -= 2;
			for (int i = 3; k > 1; k--, i++) cout << i << " ";
			cout << '\n';
		}
		else
		{
			for (int i = 1; i <= n, k > 4; i++, k--)
			{
				if (i == ans - 2)
				{
					break;
				}
				cout << i << " ";
			}
			cout << ans - 2 << " " << ans - 1 << " " << ans << " ";
			k -= 3;
			for (int i = ans + 1; i <=n, k > 1; k--, i++) cout << i << " ";
			cout << '\n';
		}
		#endif
	}
}