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

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

    int n, k;
    cin >> n >> k;
    if(k > 3)
    {
        int pre = 0;
        int cur = 0;
        for(int i = 0; i < n; i++)
        {
            cin >> cur;
            if(i == 0)
            {
                pre = cur;
                continue;
            }
            if(cur < pre)
            {
                cout << "TAK\n";
                if(i == n - 1)
                {
                    i--;
                }
                for(int j = 1; j < i - 1 && j < k - 2; j++)
                {
                    cout << j << " ";
                }
                cout << i << " " << i + 1 << " ";
                for(int j = i + 2; j < k; j++)
                {
                    cout << j << " ";
                }
                return 0;
            }
            pre = cur;
        }
        cout << "NIE";
    }
    else if(k == 3)
    {
        int x;
        int maxi = 0;
        int maxx = 0;
        int mini = 0;
        int minx = 1000000001;
        for(int i = 0; i < n; i++)
        {
            cin >> x;
            if(x >= maxx) maxi = i, maxx = x;
            if(x < minx) mini = i, minx = x;
        }
        if(maxi < n - 1)
        {
            cout << "TAK\n" << maxi << " " << maxi + 1;
        }
        else if(mini > 0)
        {
            cout << "TAK\n" << mini << " " << mini + 1;
        }
        else cout << "NIE";
    }
    else
    {
        int ciag[n];
        int mini[n];
        int maxi[n];
        for(int i = 0; i < n; i++)
        {
            cin >> ciag[i];
            if(i > 0) mini[i] = min(ciag[i], mini[i - 1]);
            else mini[i] = ciag[i];
        }
        for(int i = n - 1; i > 0; i--)
        {
            if(i < n - 1) maxi[i] = max(ciag[i], maxi[i + 1]);
            else maxi[i] = ciag[i];
            if(mini[i - 1] > maxi[i])
            {
                cout << "TAK\n" << i;
                return 0;
            }
        }
        cout << "NIE";
    }
}