#include <bits/stdc++.h> #define pb push_back using namespace std; int main() { std::ios::sync_with_stdio(false); int n; string task_types[15] = {"1A", "1B", "1C", "2A", "2B", "2C", "3A", "3B", "3C", "4A", "4B", "4C", "5A", "5B", "5C"}; std::map<string,int> counters; for (int i=0; i<15; i++) { counters.insert(std::pair<string,int>(task_types[i], 0)); } cin >> n; string s; for (int i=0; i<n; i++) { cin >> s; string task = std::string() + s[0] + s[1]; counters[task] += 1; } bool is_solution = true; for (int i=0; i<12; i++) { if (counters[task_types[i]] < 1) { is_solution = false; break; } } for (int i=12; i<15; i++) { if (counters[task_types[i]] < 2) { is_solution = false; break; } } if (is_solution) { cout << "TAK" << endl; } else { cout << "NIE" << endl; } 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 | #include <bits/stdc++.h> #define pb push_back using namespace std; int main() { std::ios::sync_with_stdio(false); int n; string task_types[15] = {"1A", "1B", "1C", "2A", "2B", "2C", "3A", "3B", "3C", "4A", "4B", "4C", "5A", "5B", "5C"}; std::map<string,int> counters; for (int i=0; i<15; i++) { counters.insert(std::pair<string,int>(task_types[i], 0)); } cin >> n; string s; for (int i=0; i<n; i++) { cin >> s; string task = std::string() + s[0] + s[1]; counters[task] += 1; } bool is_solution = true; for (int i=0; i<12; i++) { if (counters[task_types[i]] < 1) { is_solution = false; break; } } for (int i=12; i<15; i++) { if (counters[task_types[i]] < 2) { is_solution = false; break; } } if (is_solution) { cout << "TAK" << endl; } else { cout << "NIE" << endl; } return 0; } |