#include <iostream> #include <string> #include <unordered_map> /* 19 3B 4B 5B 4C 5C 3C 1A 5A 5C 3A 5A 2C 1B 2A 5B 5C 2B 1C 4A 20 2B 4B 4C 5A 5C 5C 4A 1B 3A 4A 2A 3B 1B 1C 1A 5A 2C 1B 5B 3C */ int main() { int n; std::cin >> n; std::unordered_map<std::string, int> idea_count; for (int i = 0; i < n; i++) { std::string idea; std::cin >> idea; if (idea_count.count(idea) == 0) { idea_count[idea] = 1; } else { idea_count[idea]++; } } bool enough_ideas = true; for (char division = 'A'; division <= 'C'; division++) { for (char round = '1'; round <= '4'; round++) { std::string task{}; task += round; task += division; if (idea_count.count(task) == 0 || idea_count[task] < 1) { enough_ideas = false; break; } } std::string task{}; task += '5'; task += division; if (idea_count.count(task) == 0 || idea_count[task] < 2) { enough_ideas = false; break; } } std::cout << (enough_ideas ? "TAK" : "NIE") << "\n"; }
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 | #include <iostream> #include <string> #include <unordered_map> /* 19 3B 4B 5B 4C 5C 3C 1A 5A 5C 3A 5A 2C 1B 2A 5B 5C 2B 1C 4A 20 2B 4B 4C 5A 5C 5C 4A 1B 3A 4A 2A 3B 1B 1C 1A 5A 2C 1B 5B 3C */ int main() { int n; std::cin >> n; std::unordered_map<std::string, int> idea_count; for (int i = 0; i < n; i++) { std::string idea; std::cin >> idea; if (idea_count.count(idea) == 0) { idea_count[idea] = 1; } else { idea_count[idea]++; } } bool enough_ideas = true; for (char division = 'A'; division <= 'C'; division++) { for (char round = '1'; round <= '4'; round++) { std::string task{}; task += round; task += division; if (idea_count.count(task) == 0 || idea_count[task] < 1) { enough_ideas = false; break; } } std::string task{}; task += '5'; task += division; if (idea_count.count(task) == 0 || idea_count[task] < 2) { enough_ideas = false; break; } } std::cout << (enough_ideas ? "TAK" : "NIE") << "\n"; } |