#include "bits/stdc++.h" using namespace std; vector <string> z; int main() { int n; int l = 0; string p; int a = 0; int b = 0; int c = 0; ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; z.reserve(n); for (int i = 0; i < n; i++) { cin >> p; z.push_back(p); } for (int i = 1; i <= 5; i++) { for (int j = 0; j < n; j++) { p = z[j]; if (p[1] == 'A' && p[0] == ((char)(i+48))) a++; else if (p[1] == 'B' && p[0] == ((char)(i+48))) b++; else if (p[1] == 'C' && p[0] == ((char)(i+48))) c++; } if (i < 5) if (a >= 1 && b >= 1 && c >= 1) l++; if (i == 5) if (a >= 2 && b >= 2 && c >= 2) l++; //cout << a << " " << b << " " << c << '\n'; a = 0; b = 0; c = 0; } if (l != 5) cout << "NIE"; else cout << "TAK"; exit(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 54 55 56 57 58 59 60 61 62 63 64 65 66 | #include "bits/stdc++.h" using namespace std; vector <string> z; int main() { int n; int l = 0; string p; int a = 0; int b = 0; int c = 0; ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; z.reserve(n); for (int i = 0; i < n; i++) { cin >> p; z.push_back(p); } for (int i = 1; i <= 5; i++) { for (int j = 0; j < n; j++) { p = z[j]; if (p[1] == 'A' && p[0] == ((char)(i+48))) a++; else if (p[1] == 'B' && p[0] == ((char)(i+48))) b++; else if (p[1] == 'C' && p[0] == ((char)(i+48))) c++; } if (i < 5) if (a >= 1 && b >= 1 && c >= 1) l++; if (i == 5) if (a >= 2 && b >= 2 && c >= 2) l++; //cout << a << " " << b << " " << c << '\n'; a = 0; b = 0; c = 0; } if (l != 5) cout << "NIE"; else cout << "TAK"; exit(0); } |