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<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	int k;
	int a;
	int max;
	int min;
	bool spr;
	vector<int>dane;
	vector<int> odLewej;
	vector<int> odPrawej;
	vector<int> konce;
	odLewej.push_back(1000000001);
	odPrawej.push_back(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		dane.push_back(a);
	}
	if (k == 2)
	{
		for (int i =0; i < n; i++)
		{
			if(odLewej[i]>dane[i])
				odLewej.push_back(dane[i]);
			else
				odLewej.push_back(odLewej[i]);
		}
		for (int i = 0; i < n; i++)
		{
			if (odPrawej[i] < dane[n-i-1])
				odPrawej.push_back(dane[n - i - 1]);
			else
				odPrawej.push_back(odPrawej[i]);
		}
		spr = 0;
		for (int i = 1; i < n; i++)
		{
			if (odLewej[i] >= odPrawej[n-i])//chyba w ten sposob, aby wszytstko dzialalo
			{
				cout << "TAK\n";
				cout << i<<" ";
				spr = 1;
			}
		}
		if (spr == 0)
			cout << "NIE";
	}
	else if (k == 3)
	{
		max = 0;
		min = 0;
		for (int i = 1; i < n; i++)
		{
			if (dane[i] <= dane[min])
				min = i;
			if (dane[i] > dane[max])
				max = i;
		}
		if (min != 0)
		{
			if (min == n - 1)
				cout << "TAK\n" << min - 1 << " " << min;
			else
				cout<< "TAK\n" << min  << " " << min+1;
		}
		else if (max!= n-1)
		{
			if (max == 0)
				cout << "TAK\n" << max+1 << " " << max+2;
			else
				cout << "TAK\n" << max << " " << max + 1;
		}
		else
			cout << "NIE";
	}
	else
	{
		spr = 0;
		for (int i = 1; i < n; i++)
		{
			if (dane[i] <= dane[i - 1])
			{
				spr = 1;
				cout << "TAK\n";
				konce.push_back(i);
				if (i + 1 != n)
					konce.push_back(i + 1);
				break;
			}
		}
		if (spr == 0)
			cout << "NIE";
		if (spr == 1)
		{
			for (int i = 1; i < n;i++) 
			{
				if (i != konce[0])
					konce.push_back(i);
				if (konce.size() == k - 1)
					break;
			}
			sort(konce.begin(), konce.end());
			for (int i = 0; i < konce.size(); i++)
				cout << konce[i] << " ";
		}
	}
	return 0;
}