#include <iostream> #include <string> #include <vector> using namespace std; inline int myhash(int level, char division) { return 3 * (level - 1) + static_cast<int>(division - 'A'); } inline bool verify(vector<int>& vec) { int i = 0; for (; i <= myhash(4, 'C'); i++) { if (vec[i] < 1) return false; } for (; i < myhash(5, 'C'); i++) { if (vec[i] < 2) return false; } return true; } int main() { int n; cin >> n; vector<int> vec(n); for (int i = 0; i < n; i++) { string inp; cin >> inp; vec[myhash(static_cast<int>(inp[0] - '0'), inp[1])]++; } cout << (verify(vec) ? "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 25 26 27 28 29 30 31 32 | #include <iostream> #include <string> #include <vector> using namespace std; inline int myhash(int level, char division) { return 3 * (level - 1) + static_cast<int>(division - 'A'); } inline bool verify(vector<int>& vec) { int i = 0; for (; i <= myhash(4, 'C'); i++) { if (vec[i] < 1) return false; } for (; i < myhash(5, 'C'); i++) { if (vec[i] < 2) return false; } return true; } int main() { int n; cin >> n; vector<int> vec(n); for (int i = 0; i < n; i++) { string inp; cin >> inp; vec[myhash(static_cast<int>(inp[0] - '0'), inp[1])]++; } cout << (verify(vec) ? "TAK" : "NIE"); return 0; } |