#include <bits/stdc++.h> using namespace std; #define bit(n, i) ((n>>i) & 1) #define fi first #define se second #define pb push_back #define cat(x) cerr << #x " = " << x << "\n" using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using ld = long double; int cnt[5][3]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for(int i = 1; i <= n; ++i) { char c1, c2; cin >> c1 >> c2; int x = c1-'1'; int y = c2-'A'; cnt[x][y]++; } bool ok = true; for(int i = 0; i < 4; ++i) { if(cnt[i][0] == 0 || cnt[i][1] == 0 || cnt[i][2] == 0) ok = false; } if(cnt[4][0] <= 1 || cnt[4][1] <= 1 || cnt[4][2] <= 1) ok = false; cout << (ok ? "TAK" : "NIE"); 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 | #include <bits/stdc++.h> using namespace std; #define bit(n, i) ((n>>i) & 1) #define fi first #define se second #define pb push_back #define cat(x) cerr << #x " = " << x << "\n" using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using ld = long double; int cnt[5][3]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for(int i = 1; i <= n; ++i) { char c1, c2; cin >> c1 >> c2; int x = c1-'1'; int y = c2-'A'; cnt[x][y]++; } bool ok = true; for(int i = 0; i < 4; ++i) { if(cnt[i][0] == 0 || cnt[i][1] == 0 || cnt[i][2] == 0) ok = false; } if(cnt[4][0] <= 1 || cnt[4][1] <= 1 || cnt[4][2] <= 1) ok = false; cout << (ok ? "TAK" : "NIE"); return 0; } |