#include <iostream>
#include <unordered_map>
#include <string>
#define FOR(i, n) for(int i = 1; i <= n; i++)
std::unordered_map<std::string, int> map;
bool check() {
FOR(i, 4) {
if (map[std::to_string(i) + "A"] < 1 || map[std::to_string(i) + "B"] < 1 || map[std::to_string(i) + "C"] < 1) return false;
}
if (map["5A"] < 2 || map["5B"] < 2 || map["5C"] < 2) return false;
return true;
}
int main()
{
std::ios_base::sync_with_stdio(0);
std::cin.tie(0);
int value;
std::cin >> value;
FOR(i, 5) {
map[std::to_string(i) + "A"] = 0;
map[std::to_string(i) + "B"] = 0;
map[std::to_string(i) + "C"] = 0;
}
FOR(i, value) {
std::string name;
std::cin >> name;
map[name]++;
}
std::cout << (check() ? "TAK" : "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 | #include <iostream> #include <unordered_map> #include <string> #define FOR(i, n) for(int i = 1; i <= n; i++) std::unordered_map<std::string, int> map; bool check() { FOR(i, 4) { if (map[std::to_string(i) + "A"] < 1 || map[std::to_string(i) + "B"] < 1 || map[std::to_string(i) + "C"] < 1) return false; } if (map["5A"] < 2 || map["5B"] < 2 || map["5C"] < 2) return false; return true; } int main() { std::ios_base::sync_with_stdio(0); std::cin.tie(0); int value; std::cin >> value; FOR(i, 5) { map[std::to_string(i) + "A"] = 0; map[std::to_string(i) + "B"] = 0; map[std::to_string(i) + "C"] = 0; } FOR(i, value) { std::string name; std::cin >> name; map[name]++; } std::cout << (check() ? "TAK" : "NIE") << "\n"; return 0; } |
English