#include<cstdio> int counter[20]; bool solve() { for (int i = 0; i < 3; ++i) for (int j = 0; j < 5; ++j) if (counter[5 * i + j] < ((j < 4) ? 1 : 2)) return false; return true; } int main() { int n; char input[3]; scanf("%d", &n); for (int i = 0; i < n; ++i) { scanf("%s", input); int id = input[0] - '1' + 5 * (input[1] - 'A'); counter[id]++; } printf("%s\n", solve() ? "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 | #include<cstdio> int counter[20]; bool solve() { for (int i = 0; i < 3; ++i) for (int j = 0; j < 5; ++j) if (counter[5 * i + j] < ((j < 4) ? 1 : 2)) return false; return true; } int main() { int n; char input[3]; scanf("%d", &n); for (int i = 0; i < n; ++i) { scanf("%s", input); int id = input[0] - '1' + 5 * (input[1] - 'A'); counter[id]++; } printf("%s\n", solve() ? "TAK" : "NIE"); return 0; } |