#include <iostream> using namespace std; int main() { int n; cin >> n; int cntA[5] = { 0,0,0,0,0 }; int cntB[5] = { 0,0,0,0,0 }; int cntC[5] = { 0,0,0,0,0 }; for (int i = 0; i < n; i++) { int a; char b; cin >> a >> b; if (b == 'A') { cntA[a - 1]++; } if (b == 'B') { cntB[a - 1]++; } if (b == 'C') { cntC[a - 1]++; } } for (int i = 0; i < 5; i++) { if (i != 4) { if (cntA[i] == 0 || cntB[i] == 0 || cntC[i] == 0) { cout << "NIE"; return 0; } } else if(cntA[i] < 2 || cntB[i] < 2 || cntC[i] < 2) { cout << "NIE"; return 0; } } cout << "TAK"; 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 44 45 46 47 48 49 50 51 | #include <iostream> using namespace std; int main() { int n; cin >> n; int cntA[5] = { 0,0,0,0,0 }; int cntB[5] = { 0,0,0,0,0 }; int cntC[5] = { 0,0,0,0,0 }; for (int i = 0; i < n; i++) { int a; char b; cin >> a >> b; if (b == 'A') { cntA[a - 1]++; } if (b == 'B') { cntB[a - 1]++; } if (b == 'C') { cntC[a - 1]++; } } for (int i = 0; i < 5; i++) { if (i != 4) { if (cntA[i] == 0 || cntB[i] == 0 || cntC[i] == 0) { cout << "NIE"; return 0; } } else if(cntA[i] < 2 || cntB[i] < 2 || cntC[i] < 2) { cout << "NIE"; return 0; } } cout << "TAK"; return 0; } |