#include <string> #include <iostream> #include <vector> using namespace std; int num(char a) { switch(a) { case 'A': return 0; case 'B': return 1; case 'C': return 2; } } int main() { vector<int> t[5]; for(int i = 0;i < 5;i++) { for(int o = 0;o < 3;o++) { t[i].push_back(0); } } int n,con; cin >> n; string a; vector<string> arr; for(int i = 0; i < n; i++) { cin >> a; arr.push_back(a); } for(int i = 0; i < n; i++) { con = arr[i][0] - 48; switch(con) { case 1: if(t[0][num(arr[i][1])] == 1) break; t[0][num(arr[i][1])]++; break; case 2: if(t[1][num(arr[i][1])] == 1) break; t[1][num(arr[i][1])]++; break; case 3: if(t[2][num(arr[i][1])] == 1) break; t[2][num(arr[i][1])]++; break; case 4: if(t[3][num(arr[i][1])] == 1) break; t[3][num(arr[i][1])]++; break; case 5: if(t[4][num(arr[i][1])] == 2) break; t[4][num(arr[i][1])]++; break; } } for(int i = 0;i < 5;i++) { for(int o = 0;o < 3;o++) { if((t[i][o] == 0 && i < 4) || (t[i][o] < 2 && i == 4)) { 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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | #include <string> #include <iostream> #include <vector> using namespace std; int num(char a) { switch(a) { case 'A': return 0; case 'B': return 1; case 'C': return 2; } } int main() { vector<int> t[5]; for(int i = 0;i < 5;i++) { for(int o = 0;o < 3;o++) { t[i].push_back(0); } } int n,con; cin >> n; string a; vector<string> arr; for(int i = 0; i < n; i++) { cin >> a; arr.push_back(a); } for(int i = 0; i < n; i++) { con = arr[i][0] - 48; switch(con) { case 1: if(t[0][num(arr[i][1])] == 1) break; t[0][num(arr[i][1])]++; break; case 2: if(t[1][num(arr[i][1])] == 1) break; t[1][num(arr[i][1])]++; break; case 3: if(t[2][num(arr[i][1])] == 1) break; t[2][num(arr[i][1])]++; break; case 4: if(t[3][num(arr[i][1])] == 1) break; t[3][num(arr[i][1])]++; break; case 5: if(t[4][num(arr[i][1])] == 2) break; t[4][num(arr[i][1])]++; break; } } for(int i = 0;i < 5;i++) { for(int o = 0;o < 3;o++) { if((t[i][o] == 0 && i < 4) || (t[i][o] < 2 && i == 4)) { cout << "NIE"; return 0; } } } cout << "TAK"; return 0; } |