#include <iostream> #include <vector> #include <string> #include <unordered_map> std::unordered_map<std::string, int> m; std::vector<std::string> letters = {"A", "B", "C"}; bool check(std::string s, int val) { return m.find(s) != m.end() && m[s] >= val; } int main() { std::iostream::sync_with_stdio(false); int n; std::cin >> n; while (n--) { std::string s; std::cin >> s; m[s]++; } if (!check("5A", 2) || !check("5B", 2) || !check("5C", 2)) { std::cout << "NIE"; return 0; } for (int i = 1; i <= 4; ++i) { for (const auto& letter : letters) { auto s = (char)(i + '0') + letter; if (!check(s, 1)) { std::cout << "NIE"; return 0; } } } std::cout << "TAK"; 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 43 44 45 46 47 | #include <iostream> #include <vector> #include <string> #include <unordered_map> std::unordered_map<std::string, int> m; std::vector<std::string> letters = {"A", "B", "C"}; bool check(std::string s, int val) { return m.find(s) != m.end() && m[s] >= val; } int main() { std::iostream::sync_with_stdio(false); int n; std::cin >> n; while (n--) { std::string s; std::cin >> s; m[s]++; } if (!check("5A", 2) || !check("5B", 2) || !check("5C", 2)) { std::cout << "NIE"; return 0; } for (int i = 1; i <= 4; ++i) { for (const auto& letter : letters) { auto s = (char)(i + '0') + letter; if (!check(s, 1)) { std::cout << "NIE"; return 0; } } } std::cout << "TAK"; return 0; } |