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

using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    int ciag[n];
    int max_id = 0, min_id = 0, max_w = 0, min_w = 10000000;
    int monotonicznosc = 1, monotonicznosc_id = -1;
    int old_min = 0;
    int min_zdodnosc = 0;
    

    for(int  i = 0; i < n; i++){
        int liczba;
        cin >> liczba;
        ciag[i] = liczba;
        if(liczba > max_w){
            max_w = liczba;
            max_id = i;
        }
        if(liczba <= min_w){
            old_min = min_w;
            min_w = liczba;
            min_id = i;
            min_zdodnosc = 1;           
        }
        if(liczba > old_min){
            min_zdodnosc = 0;
        }
        if(monotonicznosc == 1 and i != 0){
            if(liczba <= ciag[i-1]){
                monotonicznosc = 0;
                monotonicznosc_id = i;
            }
        }
    }
    if(monotonicznosc == 1){
        cout << "NIE";
        return 0;
    }
    if(k == 2){
        if(min_zdodnosc == 1){
            cout << "TAK" << "\n" << min_id;
        }
        else{
            cout << "NIE";
        }
        return 0;                   
    }
    int lokalizajca_ekstremum = -1;
    
    if(max_id != n - 1){
        lokalizajca_ekstremum = max_id;
    }
    if(min_id != 0 and lokalizajca_ekstremum == -1){
        lokalizajca_ekstremum = min_id;
    }
    if(lokalizajca_ekstremum != -1){
        cout << "TAK\n";
        int k_tym = k - 3;
        for(int i = 0; i < n; i++){
            if(lokalizajca_ekstremum == i or lokalizajca_ekstremum == i - 1){
                cout << i << " ";
            }
            else{
                if(k_tym > 0){
                    cout << i << " ";
                    k_tym--; 
                }
            }
            if(k_tym <= 0 and lokalizajca_ekstremum < i){
                break;
            }
        }
        return 0;
    }
    else{
        if(k == 3){
            cout << "NIE";
        }
        else{
            cout << "TAK\n";
            int k_tym = k - 4;
            for(int i = 0; i < n; i++){
                if(monotonicznosc_id == i or monotonicznosc_id == i+1 or monotonicznosc_id == i+2){
                    k_tym++;
                }
                if(k_tym > 0){
                    cout << i << " ";
                    k_tym--;
                }
                if(k_tym == 0 and monotonicznosc_id < i){
                    break;
                }
            }
        }
    }








    return 0;
}