#include <iostream> #include <string> using namespace std; int main(int argc, char* argv[]) { int n; string str; cin >> n; getline(cin >> ws, str); int tasks[5][3]; int count = 0; for (int i = 0; i < 5; i++) { for (int j = 0; j < 3; j++) { tasks[i][j] = 0; } } int m = 3 * n; for (int i = 0; i < m; i += 3) { int l = (int)str[i] - 49; int k = (int)str[i + 1] - 65; if ((l < 4 && tasks[l][k] < 1) || (l == 4 && tasks[l][k] < 2)) { tasks[l][k]++; count++; } if (count == 18) { std::cout << "TAK"; return 0; } } if (count < 18) cout << "NIE"; }
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 <string> using namespace std; int main(int argc, char* argv[]) { int n; string str; cin >> n; getline(cin >> ws, str); int tasks[5][3]; int count = 0; for (int i = 0; i < 5; i++) { for (int j = 0; j < 3; j++) { tasks[i][j] = 0; } } int m = 3 * n; for (int i = 0; i < m; i += 3) { int l = (int)str[i] - 49; int k = (int)str[i + 1] - 65; if ((l < 4 && tasks[l][k] < 1) || (l == 4 && tasks[l][k] < 2)) { tasks[l][k]++; count++; } if (count == 18) { std::cout << "TAK"; return 0; } } if (count < 18) cout << "NIE"; } |