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

using namespace std;

int main()
{
    int n,k; cin >> n >> k;
    vector<int>V(n) ;
    for(auto &i:V) cin >> i ;
    int last=-1,x=-1 ;
    for(int i=0;i<n;i++)
    {
        if(V[i]<=last) x=i ;
        last=V[i] ;
    }
    if(x==-1)
    {
        cout << "NIE" ;
        return 0;
    }
    if(k==2)
    {
        vector<int>minnpref(n+1,inf),maxxsuff(n+1,-inf);
        for(int i=1;i<=n;i++) minnpref[i]=min(minnpref[i-1],V[i-1]) ;
        for(int i=n-1;i>=0;i--) maxxsuff[i]=max(maxxsuff[i+1],V[i]) ;
        for(int i=0;i<n-1;i++)
        {
            if(minnpref[i+1]>=maxxsuff[i+1])
            {
                cout << "TAK" << endl;
                cout << i+1;
                return 0;
            }
        }
        cout << "NIE" << endl ;
        return 0;
    }

    if(k==3)
    {
        vector<int>minnpref(n+1,inf),maxxsuff(n+1,-inf) ;
        for(int i=1;i<=n;i++) minnpref[i]=min(minnpref[i-1],V[i-1]) ;
        for(int i=n-1;i>=0;i--) maxxsuff[i]=max(maxxsuff[i+1],V[i]) ;
        for(int i=1;i<n-1;i++)
        {
            if(maxxsuff[i+1]<=V[i] || minnpref[i+1]>=V[i])
            {
                cout << "TAK" << endl ;
                if(i==0)
                {
                    cout << i+1 << " " << i+2 << endl ;
                    return 0;
                }
                cout << i << " " << i+1 << endl ;
                return 0;
            }
        }
        cout << "NIE" ;
        return 0;
    }


    cout << "TAK" << endl ;
    int y=min(x,k-3) ;
    for(int i=1;i<y;i++) cout << i << " " ;
    cout << x-1 << " " << x << " " << x+1 << " ";
    y=k-3-y;
    for(int i=x+2;i<y;i++) cout << i << " " ;

}