#include <bits/stdc++.h> using namespace std; #define pii pair<int, int> #define FOR(x, j) for(int x = 0; x < j; x++) #define ll long long const int INF = 2e9; const int maxN = 105; int T[3][5]; int n; void solve(){ cin >> n; for(int i = 0; i < n; i++){ char p, t; cin >> p >> t; int pos, type; pos = p - '0' - 1; if(t == 'A') type = 0; else if(t == 'B') type = 1; else type = 2; T[type][pos]++; } for(int i = 0; i < 3; i++) for(int j = 0; j < 4; j++) if(T[i][j] < 1){ cout << "NIE\n"; return; } for(int j = 0; j < 3; j++) if(T[j][4] < 2){ cout << "NIE\n"; return; } cout << "TAK\n"; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); bool multitest = false; //multitest = true; if (multitest) { int t; cin >> t; while (t--) solve(); } else solve(); }
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 | #include <bits/stdc++.h> using namespace std; #define pii pair<int, int> #define FOR(x, j) for(int x = 0; x < j; x++) #define ll long long const int INF = 2e9; const int maxN = 105; int T[3][5]; int n; void solve(){ cin >> n; for(int i = 0; i < n; i++){ char p, t; cin >> p >> t; int pos, type; pos = p - '0' - 1; if(t == 'A') type = 0; else if(t == 'B') type = 1; else type = 2; T[type][pos]++; } for(int i = 0; i < 3; i++) for(int j = 0; j < 4; j++) if(T[i][j] < 1){ cout << "NIE\n"; return; } for(int j = 0; j < 3; j++) if(T[j][4] < 2){ cout << "NIE\n"; return; } cout << "TAK\n"; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); bool multitest = false; //multitest = true; if (multitest) { int t; cin >> t; while (t--) solve(); } else solve(); } |