#include <cstdio> #include <string> #include <map> int main() { int n; scanf("%d", &n); std::map<std::string, int> cnt; for (int i = 0; i < n; ++i) { static char s[10]; scanf("%s", s); cnt[s]++; } bool valid = true; for (int i = 1; i <= 5; ++i) { int req = i <= 4 ? 1 : 2; for (char a = 'A'; a <= 'C'; ++a) { std::string s = std::to_string(i) + a; if (cnt[s] < req) valid = false; } } puts(valid ? "TAK" : "NIE"); 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 | #include <cstdio> #include <string> #include <map> int main() { int n; scanf("%d", &n); std::map<std::string, int> cnt; for (int i = 0; i < n; ++i) { static char s[10]; scanf("%s", s); cnt[s]++; } bool valid = true; for (int i = 1; i <= 5; ++i) { int req = i <= 4 ? 1 : 2; for (char a = 'A'; a <= 'C'; ++a) { std::string s = std::to_string(i) + a; if (cnt[s] < req) valid = false; } } puts(valid ? "TAK" : "NIE"); return 0; } |