//Elżbieta Łabaj
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n;
cin >> n;
vector<string> vec(n);
for (int i = 0; i < n; i++) cin >> vec[i];
if (n < 18) {
cout << "NIE\n";
return 0;
}
sort(vec.begin(), vec.end());
int i = 0;
for (int runda = 1; runda <= 5; runda++) {
for (char dyw = 'A'; dyw <= 'C'; dyw++) {
if (i >= n) {
cout << "NIE\n";
return 0;
}
string zad = "";
zad += '0' + runda;
zad += dyw;
int cnt = 0;
while (i < n && vec[i] == zad) {
cnt++;
i++;
}
if (runda == 5 ? (cnt < 2) : (cnt < 1)) {
cout << "NIE\n";
return 0;
}
}
}
cout << "TAK\n";
return 0;
}
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 | //Elżbieta Łabaj #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; cin >> n; vector<string> vec(n); for (int i = 0; i < n; i++) cin >> vec[i]; if (n < 18) { cout << "NIE\n"; return 0; } sort(vec.begin(), vec.end()); int i = 0; for (int runda = 1; runda <= 5; runda++) { for (char dyw = 'A'; dyw <= 'C'; dyw++) { if (i >= n) { cout << "NIE\n"; return 0; } string zad = ""; zad += '0' + runda; zad += dyw; int cnt = 0; while (i < n && vec[i] == zad) { cnt++; i++; } if (runda == 5 ? (cnt < 2) : (cnt < 1)) { cout << "NIE\n"; return 0; } } } cout << "TAK\n"; return 0; } |
English