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

using namespace std;

void solve4(int& n, int& k, vector<int>& v);
void solve3(int& n, int& k, vector<int>& v);
void solve2(int& n, int& k, vector<int>& v);

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin>>n>>k;
	vector<int> v(n);
	for(int i=0; i<n; i++)
		cin>>v[i];
	switch(k)
	{
		case 2: 	solve2(n, k, v); break;
		case 3: 	solve3(n, k, v); break;
		default:	solve4(n, k, v); break;
	}
	return 0;
}

void solve4(int& n, int& k, vector<int>& v)
{
	int z;
	for(z=0; z<n-1 && v[z]<v[z+1]; z++) ;
	if(z==n-1)
	{
		cout<<"NIE";
		return;
	}
	cout<<"TAK\n";
	if(z==n-2)
	{
		for(int i=1; i<k-2; i++)
			cout<<i<<" ";
		cout<<z<<" "<<z+1;
		return;
	}
	if(z>k-4)
	{
		for(int i=1; i<k-3; i++)
			cout<<i<<" ";
		cout<<z<<" "<<z+1<<" "<<z+2;
		return;
	}
	for(int i=1; i<k; i++)
		cout<<i<<" ";
}

void solve3(int& n, int& k, vector<int>& v)
{
	int mini = n-1, maxi = 0;
	for(int i=1; i<n; i++)
		maxi = (v[maxi]>=v[i])?maxi:i;
	for(int i=n-2; i>=0; i--)
		mini = (v[mini]<=v[i])?mini:i;
	if(mini != 0)
	{
		cout<<"TAK\n";
		if(mini == n-1)
			cout<<"0 "<<mini;
		else
			cout<<mini<<" "<<mini+1;
		return;
	}
	if(maxi != n-1)
	{
		cout<<"TAK\n";
		cout<<maxi<<" "<<maxi+1;
		return;
	}
	cout<<"NIE";
}

void solve2(int& n, int& k, vector<int>& v)
{
	vector<int> mins(n);
	vector<int> maxs(n);
	mins[0] = v[0];
	maxs[n-1] = v[n-1];
	for(int i=1; i<n-1; i++)
	{
		mins[i] = (v[i]<mins[i-1])?v[i]:mins[i-1];
	}
	for(int i=n-2; i>0; i--)
	{
		maxs[i] = (v[i]>maxs[i+1])?v[i]:maxs[i+1];
	}
	for(int i=1; i<n; i++)
	{
		if(maxs[i]<=mins[i-1])
		{
			cout<<"TAK\n"<<i;
			return;
		}
	}
	cout<<"NIE";
}