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
#include <algorithm>
#include <cstdio>
#include <vector>
#include <set>

using namespace std;

long a[500001];
long al[500001];
long ah[500001];

int main()
{
	long n, k;
	scanf("%ld %ld", &n, &k);

	if (k == 2)
	{
		scanf("%ld", &a[0]);
		al[0] = a[0];
		for (long i = 1; i < n; ++i)
		{
			scanf("%ld", &a[i]);
			al[i] = a[i] < al[i - 1] ? a[i] : al[i - 1];
		}
		long h = a[n - 1];
		while (--n > 0)
		{
			if (h < a[n])
				h = a[n];
			if (h <= al[n - 1])
			{
				printf("%s\n", "TAK");
				printf("%ld", n);
				return 0;
			}
		}
		printf("%s\n", "NIE");
		return 0;
	}

	if (k == 3)
	{
		scanf("%ld", &a[0]);
		long l = a[0];
		for (long i = 1; i < n; ++i)
		{
			scanf("%ld", &a[i]);
			if (a[i] <= l)
			{
				printf("%s\n", "TAK");
				if (i + 1 == n)
					--i;
				printf("%ld %ld", i, i + 1);
				return 0;
			}
		}
		long h = a[n - 1];
		for (long i = n - 2; i >= 0; --i)
		{
			if (a[i] >= h)
			{
				printf("%s\n", "TAK");
				if (i == 0)
					++i;
				printf("%ld %ld", i, i + 1);
				return 0;
			}
		}
		printf("%s\n", "NIE");
		return 0;
	}

	scanf("%ld", &a[0]);
	for (long i = 1; i < n; ++i)
	{
		scanf("%ld", &a[i]);
		if (a[i] <= a[i - 1])
		{
			printf("%s\n", "TAK");

			if (i + 1 == n)
				--i;
			if (i - 1 == 0)
				++i;
			long r = 1;
			while (k > 1)
			{
				if (k > 4 || r >= i - 1)
				{
					printf("%ld ", r);
					--k;
				}
				++r;
			}
			return 0;
		}
	}
	printf("%s\n", "NIE");
	return 0;
}