#include <iostream> #include <vector> using namespace std; int main() { int num; cin >> num; vector<int> mins = {1, 1, 1, 1, 2}; vector<vector<int>> sums = { {0, 0, 0, 0, 0}, // A {0, 0, 0, 0, 0}, // B {0, 0, 0, 0, 0} // C }; for (int i = 0; i < num; i++) { string s; cin >> s; char zad = s[0]; char dyw = s[1]; sums[dyw - 'A'][zad - '0' - 1]++; } bool good = true; for (auto &dyw : sums) { for (int zadId = 0; zadId < 5; zadId++) { if (dyw[zadId] < mins[zadId]) { good = false; break; } } if (!good) { break; } } cout << (good ? "TAK" : "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 | #include <iostream> #include <vector> using namespace std; int main() { int num; cin >> num; vector<int> mins = {1, 1, 1, 1, 2}; vector<vector<int>> sums = { {0, 0, 0, 0, 0}, // A {0, 0, 0, 0, 0}, // B {0, 0, 0, 0, 0} // C }; for (int i = 0; i < num; i++) { string s; cin >> s; char zad = s[0]; char dyw = s[1]; sums[dyw - 'A'][zad - '0' - 1]++; } bool good = true; for (auto &dyw : sums) { for (int zadId = 0; zadId < 5; zadId++) { if (dyw[zadId] < mins[zadId]) { good = false; break; } } if (!good) { break; } } cout << (good ? "TAK" : "NIE") << endl; return 0; } |