#include <iostream> #include <string> using namespace std; int main() { int n = 0; cin >> n; string z[n]; bool rest[4][3]; bool check = true; for(int i=0; i<4; i++){ rest[i][0] = false; rest[i][1] = false; rest[i][2] = false; } int five[3]; five[0] = 0; five[1] = 0; five[2] = 0; for(int i=0; i<n; i++){ int x = -1; int y = 0; z[i] = ""; cin >> z[i]; switch(z[i].at(1)){ case 'A': x = 0; break; case 'B': x = 1; break; case 'C': x=2; break; } y = (int)z[i].at(0) - 48; if(y > 0 && y < 6 && x!= -1){ if(y == 5){ five[x]++; } else{ rest[y-1][x] = true; } } } for(int i=0; i<4; i++){ if(!(rest[i][0]) || !(rest[i][1]) || !(rest[i][2])) check = false; } if(five[0] < 2 || five[1] < 2 || five[2] < 2) check = false; if(check) cout << "TAK"; else cout << "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 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> #include <string> using namespace std; int main() { int n = 0; cin >> n; string z[n]; bool rest[4][3]; bool check = true; for(int i=0; i<4; i++){ rest[i][0] = false; rest[i][1] = false; rest[i][2] = false; } int five[3]; five[0] = 0; five[1] = 0; five[2] = 0; for(int i=0; i<n; i++){ int x = -1; int y = 0; z[i] = ""; cin >> z[i]; switch(z[i].at(1)){ case 'A': x = 0; break; case 'B': x = 1; break; case 'C': x=2; break; } y = (int)z[i].at(0) - 48; if(y > 0 && y < 6 && x!= -1){ if(y == 5){ five[x]++; } else{ rest[y-1][x] = true; } } } for(int i=0; i<4; i++){ if(!(rest[i][0]) || !(rest[i][1]) || !(rest[i][2])) check = false; } if(five[0] < 2 || five[1] < 2 || five[2] < 2) check = false; if(check) cout << "TAK"; else cout << "NIE"; return 0; } |