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
#include <bits/stdc++.h>

using namespace std;

constexpr int MAXN=5e5+7;
int tab[MAXN];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, k, a, mini, pozycja=0;
    bool mozliwe;

    cin >> n >> k;

    for (int i=1; i <= n; i++)
        cin >> tab[i];

    if (k == 2) {
        mini = tab[1];
        mozliwe = 0;
        
        for (int i=2; i <= n; i++) {
            if (tab[i] <= mini) {
                mozliwe = 1;
                pozycja = i-1;

                for (i; i <= n; i++) {
                    if (tab[i] > mini) {
                        mozliwe = 0;
                        break;
                    }
                }
            }
        }

        if (mozliwe)
            cout << "TAK\n" << pozycja;

        else
            cout << "NIE";
    }

    else {
        mini = tab[1];

        for (int i=2; i <= n; i++) {
            if (tab[i] <= mini) {
                pozycja = i;
            }
        }

        if (pozycja != 0) {
            cout << "TAK\n";

            bool a1=0, a2=0;

            for (int i=1; i < n && k-3 > 0; i++) {
                if (i == pozycja-1) {
                    k++;
                    a1 = 1;
                }
                if (i == pozycja) {
                    k++;
                    a2 = 1;
                }

                cout << i << ' ';
                k--;
            }

            if (!a1 && !a2)
                cout << pozycja-1 << ' ' << pozycja;

            else if (!a2)
                cout << pozycja;
        }

        else
            cout << "NIE";
    }

    return 0;
}