#include <bits/stdc++.h> using namespace std; int tab[3][5]; int main() { int N; cin >> N; while(N--) { string a; cin >> a; int t, p; if (a[1] == 'A') t = 0; if (a[1] == 'B') t = 1; if (a[1] == 'C') t = 2; if (a[0] == '1') p = 0; if (a[0] == '2') p = 1; if (a[0] == '3') p = 2; if (a[0] == '4') p = 3; if (a[0] == '5') p = 4; tab[t][p]++; } for(int i = 0; i < 3; ++i) { for (int j = 0; j < 5; ++j) { int ile = j == 4 ? 2 : 1; if (tab[i][j] < ile) { 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 | #include <bits/stdc++.h> using namespace std; int tab[3][5]; int main() { int N; cin >> N; while(N--) { string a; cin >> a; int t, p; if (a[1] == 'A') t = 0; if (a[1] == 'B') t = 1; if (a[1] == 'C') t = 2; if (a[0] == '1') p = 0; if (a[0] == '2') p = 1; if (a[0] == '3') p = 2; if (a[0] == '4') p = 3; if (a[0] == '5') p = 4; tab[t][p]++; } for(int i = 0; i < 3; ++i) { for (int j = 0; j < 5; ++j) { int ile = j == 4 ? 2 : 1; if (tab[i][j] < ile) { cout << "NIE\n"; return 0; } } } cout << "TAK\n"; return 0; } |