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
#include<iostream>
#include<map>
#include<set>
using namespace std;

int T[1000007];

int f(int n, int p, int a){ //a bedie 0
    int maks=0, minn=0;
    for (int i=a; i<n-a; i++){
        if (T[i]>=T[maks]) maks=i;
        if (T[i]<T[minn]) minn=i;
    }
    //cout<<maks<<" "<<minn<<"\n";
    if (maks!=n-1-a){
        cout<<"TAK \n";
        for (int i=maks-p+3; i<maks+2; i++){
            cout<<i<<" ";
        }
        cout<<"\n";
        return 0;
    }
    if (minn!=a){
        cout<<"TAK \n";
        for (int i=minn; i<minn+p-1; i++){
            cout<<i<<" ";
        }
        cout<<"\n";
        return 0;
    }
    else if (p-2>1){
        f(n, p-2, a+1);
    }
    else{
        cout<<"NIE \n";
        return 0;
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, p; cin>>n>>p;
    for (int i=0; i<n; i++) cin>>T[i];
    f(n, p, 0);
}