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 // Mateusz Bogusławski #include #include using namespace std; int main() { int n, k, l[500000]; cin >> n >> k; for (int i = 0; i < n; i++) { cin >> l[i]; } int t[500000]; int max = l[n-1]; for (int i = n-1; i > -1; i--) { if (l[i] > max) { max = l[i]; } t[i] = max; } if (k == 2) { int min = l[0]; for (int i = 0; i < n-1; i++) { if (l[i] < min) { min = l[i]; } if (min >= t[i+1]) { cout << "TAK\n" << i+1 << endl; return 0; } } cout << "NIE" << endl; return 0; } int indx1 = -1, indx2 = -1; for (int i = 0; i < n-1; i++) { if (l[i] == t[0]) { if (i != 0) { indx1 = i; k--; } indx2 = i+1; k--; break; } } if ( (indx2 == -1) && (indx1 == -1) ) { cout << "NIE" << endl; return 0; } cout << "TAK\n"; bool f1 = false, f2 = false; for (int i = 0; i < k-1; i++) { if (i+1 == indx1) { k++; f1 = true; } if (i+1 == indx2) { k++; f2 = true; } cout << i+1 << " "; } if (!f1) { cout << indx1 << " "; } if (!f2) { cout << indx2 << " "; } cout << endl; }