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
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

using namespace std;
const int maxx = 5e5+7;

int tab[maxx];
int n,k;
void solve()
{
    int maxi = -1;
    bool flaga = 0;
    int x,y;
    for(int i=0; n>i; i++)
    {
        if(tab[i]<=maxi)
        {
            flaga = 1;
            y = i+1;
            break;
        }
        else
        {
            maxi = tab[i];
            x = i+1;
        }
    }
    if(flaga)
    {
        cout<<"TAK"<<endl;
        set<int>secik;
        secik.insert(x);
        secik.insert(y);
        int pom = 1;
        while(secik.size()!=k-1)
        {
            secik.insert(pom);
            pom++;
        }
        if(y == n) secik.insert(pom);
        auto it = secik.begin();
        for(; it != secik.end(); it++)
        {
            if(*it != n)
            {
                cout<<*it<<" ";
            }
        }
    }
    else cout<<"NIE";
}

void solve2()
{
    multiset<int>secik; secik.clear();
    for(int i=0; n>i; i++) secik.insert(tab[i]);
    int maxi = int(1e9)+7;
    for(int i=0; n-1>i; i++)
    {
        maxi = min(maxi, tab[i]);
        secik.erase(secik.find(tab[i]));
        auto it = secik.end(); it--;
        if(maxi >= *it)
        {
            cout<<"TAK"<<endl;
            cout<<i+1;
            return;
        }
    }
    cout<<"NIE";
}

void solve3()
{
    int mini = tab[0];
    for(int i=1; n>i; i++)
    {
        if(tab[i]<=mini)
        {
            cout<<"TAK"<<endl;
            if(i == n-1)
            {
                cout<<"1 "<<i<<endl;
                return;
            }
            else
            {
                cout<<i<<" "<<i+1<<endl;
                return;
            }
            return;
        }
        mini = min(mini,tab[i]);
        
    }
    cout<<"NIE";
}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>k;
    for(int i=0; n>i; i++)
    {
        cin>>tab[i];
    }
    if(k>3) solve();
    else if(k == 2) solve2();
    else solve3();
}
/*

6 3
3 5 4 8 3 7



*/