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
#include<vector>
#include <iostream>
#include<algorithm>
#include<queue>
#include<bitset>
using namespace std;
typedef long long ll;
#define f first
#define s second
#define pb push_back
int n,k,ile;
bitset<500011> poz;
int A[500001],mini[500001],maxi[500001];
int main()
{ ios_base::sync_with_stdio(); cin.tie();
    cin>>n>>k;
    ile=k-1;
    for(int i=0;i<n;i++)
        cin>>A[i];
    for(int i=1;i<n;i++)
    {if(A[i]<=A[i-1])break;
        if(i==n-1){cout<<"NIE"; return 0;}
    }
    if(k>=4)
    { cout<<"TAK\n";
        for(int i=1;i<n;i++)
            if(A[i]<=A[i-1]){poz[i-1]=1; poz[i]=1; poz[i+1]=1; ile-=3; if(i==n-1)ile++; if(i==1)ile++; break;}
        
    }
    if(k==3)
    {
        for(int i=1;i<n;i++)if(A[i]<=A[0]){cout<<"TAK\n"; poz[i].flip(); poz[i+1].flip(); ile-=2; if(i==n-1)ile++; break;}
for(int i=n-2;i>=1;i++)if(A[i]>=A[n-1]){cout<<"TAK\n"; poz[i].flip(); poz[i+1].flip(); ile-=2;  break;}
    }
    if(k==2)
    {
        mini[0]=A[0];
        for(int i=1;i<n;i++)
            mini[i]=min(mini[i-1],A[i]);
        maxi[n-1]=A[n-1];
        for(int i=n-2;i>=0;i--)maxi[i]=max(maxi[i+1],A[i]);
        for(int i=0;i<n-1;i++)if(mini[i]>=maxi[i+1]){poz[i+1].flip(); ile--; break;}
        
        
    }
    if(ile==k-1){cout<<"NIE"; return 0;}
    for(int i=1;i<n;i++){if(ile==0)break; if(poz[i]==0){poz[i].flip(); ile--;}}
    for(int i=0;i<n;i++)if(poz[i])cout<<i<<' ';
    
    return 0;
}