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
/*
    Zadanie: Podwyżki
    Autor: Tomasz Kwiatkowski
*/

#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
typedef long long ll;

const int MAXN = 5e5 + 7;

int arr[MAXN];
int min_pref[MAXN];
int max_suf[MAXN];
bool res[MAXN];

bool is_inc(int n)
{
    for (int i = 2; i <= n; ++i)
        if (arr[i - 1] >= arr[i])
            return false;
    return true;
}

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

    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i)
        cin >> arr[i];

    min_pref[0] = 1e9 + 7;
    for (int i = 1; i <= n; ++i)
        min_pref[i] = min(min_pref[i - 1], arr[i]);
    for (int i = n; i >= 1; --i)
        max_suf[i] = max(max_suf[i + 1], arr[i]);

    if (is_inc(n)) {
        cout << "NIE\n";
        return 0;
    }

    bool ok = false;
    if (k >= 2) {
        for (int i = 1; i < n; ++i) {
            if (min_pref[i] >= max_suf[i + 1]) {
                res[i] = 1;
                k -= 2;
                ok = true;
                break;
            }
        }
    }
    if (!ok && k >= 3) {
        for (int i = 2; i < n; ++i) {
            if (min_pref[i - 1] >= arr[i] || arr[i] >= max_suf[i + 1]) {
                res[i - 1] = res[i] = 1;
                k -= 3;
                ok = true;
                break;
            }
        }
    } 
    if (!ok && k >= 4) {
        for (int i = 3; i < n; ++i) {
            if (arr[i - 1] >= arr[i]) {
                res[i - 1] = res[i] = res[i + 1] = 1;
                k -= 4;
                ok = true;
                break;
            }
        }
    }

    if (!ok) {
        cout << "NIE\n";
        return 0;
    }
    cout << "TAK\n";
    for (int i = 1; i < n; ++i) {
        if (res[i] || (k-- > 0))
            cout << i << ' ';
    }
    cout << '\n';
    return 0;
}