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

int a[500000], x[500000];

int main()
{
  int n, k, p;
  scanf("%i%i", &n, &k);
  for (int i=0; i<n; i++) scanf("%i", &a[i]);
  for (int i=n-1; i>=0; i--) x[i]=i<n-1? std::max(x[i+1],a[i]): a[i];

  if (k<2) puts("NIE");
  else
  if (k==2)
  {
    for (int i=0; i<n-1; i++)
    {
      p = i>0? std::min(p,a[i]): a[i];
      if (p >= x[i+1])
      {
        printf("TAK\n%i\n", i+1);
        return 0;
      }
    }
    puts("NIE");
  }
  else
  if (k==3)
  {
    for (int i=0; i<n-2; i++)
    {
      p = i>0? std::min(p,a[i]): a[i];
      if (p >= a[i+1] || a[i+1] >= x[i+2])
      {
        printf("TAK\n%i %i\n", i+1, i+2);
        return 0;
      }
    }
    puts("NIE");
  }
  else
  {
    for (int i=0; i<n-1; i++)
    {
      if (a[i] >= a[i+1])
      {
        puts("TAK");
        for (int j=1; j<k; j++) printf("%i%c", i+j-1+(i<1)-std::max(k+i-n-1,0), " \n"[j==k-1]);
        return 0;
      }
    }
    puts("NIE");
  }
  return 0;
}