#include <bits/stdc++.h> using namespace std; // 3B 4B {5B} 4C (5C) 3C 1A {5A} 3A {5A} 2C 1B 2A {5B} (5C) 2B 1C 4A // 1A, 1B, 1C, 2A, 2B, 2C, 3A, 3B, 3C, 4A, 4B, 4C, 5AA, 5BB, 5CC bool solution(map<char, map<char, int>> data) { for (auto &a : data) { for (auto &b : a.second) { if ((b.second <= 1) && (a.first == '5')) return false; } } return true; } int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); map<char, map<char, int>> ex; int n, i; string x; cin >> n; for (i = 0; i < n; ++i) { cin >> x; ex[(char)x[0]][(char)x[1]]++; } if (solution(ex)) { cout << "TAK" << "\n"; } else { cout << "NIE" << "\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 | #include <bits/stdc++.h> using namespace std; // 3B 4B {5B} 4C (5C) 3C 1A {5A} 3A {5A} 2C 1B 2A {5B} (5C) 2B 1C 4A // 1A, 1B, 1C, 2A, 2B, 2C, 3A, 3B, 3C, 4A, 4B, 4C, 5AA, 5BB, 5CC bool solution(map<char, map<char, int>> data) { for (auto &a : data) { for (auto &b : a.second) { if ((b.second <= 1) && (a.first == '5')) return false; } } return true; } int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); map<char, map<char, int>> ex; int n, i; string x; cin >> n; for (i = 0; i < n; ++i) { cin >> x; ex[(char)x[0]][(char)x[1]]++; } if (solution(ex)) { cout << "TAK" << "\n"; } else { cout << "NIE" << "\n"; } return 0; } |