#include <iostream> #include <vector> #include <string> int main() { std::cin.tie(0); std::ios::sync_with_stdio(0); int n; std::cin >> n; std::vector<int> a(5); std::vector<int> b(5); std::vector<int> c(5); for (int i = 0; i < n; i++) { std::string s; std::cin >> s; if (s[1] == 'A') { a[s[0] - '1']++; } else if (s[1] == 'B') { b[s[0] - '1']++; } else { c[s[0] - '1']++; } } bool out = true; for (int i = 0; i < 5; i++) { if (i != 4) { if (a[i] == 0 || b[i] == 0 || c[i] == 0) out = false; } else { if (a[i] < 2 || b[i] < 2 || c[i] < 2) out = false; } } if (out) std::cout << "TAK"; else std::cout << "NIE"; }
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 | #include <iostream> #include <vector> #include <string> int main() { std::cin.tie(0); std::ios::sync_with_stdio(0); int n; std::cin >> n; std::vector<int> a(5); std::vector<int> b(5); std::vector<int> c(5); for (int i = 0; i < n; i++) { std::string s; std::cin >> s; if (s[1] == 'A') { a[s[0] - '1']++; } else if (s[1] == 'B') { b[s[0] - '1']++; } else { c[s[0] - '1']++; } } bool out = true; for (int i = 0; i < 5; i++) { if (i != 4) { if (a[i] == 0 || b[i] == 0 || c[i] == 0) out = false; } else { if (a[i] < 2 || b[i] < 2 || c[i] < 2) out = false; } } if (out) std::cout << "TAK"; else std::cout << "NIE"; } |