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
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

const string TAK="TAK", NIE="NIE";
const int N=1000000;

int n, k;
int a[N], mi[N], ma[N];

void k2()
{
    for (int i=0; i+1<n; ++i)
        if (ma[i+1]<=mi[i])
        {
            cout<<TAK<<endl;
            cout<<(i+1)<<endl;
            return;
        }
    cout<<NIE<<endl;
}

void k3()
{
    for (int i=1; i+1<n; ++i)
        if (a[i]<=mi[i-1] || ma[i+1]<=a[i])
        {
            cout<<TAK<<endl;
            cout<<i<<' '<<(i+1)<<endl;
            return;
        }
    cout<<NIE<<endl;
}

void k4p()
{
    for (int i=0; i+1<n; ++i)
        if (a[i+1]<=a[i])
        {
            cout<<TAK<<endl;
            int a=max(1, i);
            int b=min(n-1, i+2);
            int z=k-1-(b-a+1);
            for (int j=1; j<a && 0<z; ++j, --z)
                cout<<j<<' ';
            for (int j=a; j<=b; ++j)
                cout<<j<<' ';
            for (int j=b+1; 0<z; ++j, --z)
                cout<<j<<' ';
            return;
        }
    cout<<NIE<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin>>n>>k;
    for (int i=0; i<n; ++i)
        cin>>a[i];

    for (int i=0, m=a[0]; i<n; ++i)
    {
        m=min(m, a[i]);
        mi[i]=m;
    }

    for (int i=n-1, m=a[i]; 0<=i; --i)
    {
        m=max(m, a[i]);
        ma[i]=m;
    }

    if (k==2)
        k2();
    else if (k==3)
        k3();
    else k4p();

    return 0;
}