#include<bits/stdc++.h> using namespace std; map<string,int> mapa; int main() { mapa["1A"] = 0; mapa["1B"] = 0; mapa["1C"] = 0; mapa["2A"] = 0; mapa["2B"] = 0; mapa["2C"] = 0; mapa["3A"] = 0; mapa["3B"] = 0; mapa["3C"] = 0; mapa["4A"] = 0; mapa["4B"] = 0; mapa["4C"] = 0; mapa["5A"] = 0; mapa["5B"] = 0; mapa["5C"] = 0; int n; cin >> n; for(int i = 0; i < n; i++) { string x; cin >> x; mapa[x] ++; } string x = "1A"; while(x != "5A") { if(mapa[x] == 0) { cout << "NIE"; return 0; } x[1] ++; if(x[1] == 'D') { x[0]++; x[1] = 'A'; } } while(x != "6A") { if(mapa[x] <= 1) { cout << "NIE"; return 0; } x[1] ++; if(x[1] == 'D') { x[0]++; x[1] = 'A'; } } cout << "TAK"; }
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 | #include<bits/stdc++.h> using namespace std; map<string,int> mapa; int main() { mapa["1A"] = 0; mapa["1B"] = 0; mapa["1C"] = 0; mapa["2A"] = 0; mapa["2B"] = 0; mapa["2C"] = 0; mapa["3A"] = 0; mapa["3B"] = 0; mapa["3C"] = 0; mapa["4A"] = 0; mapa["4B"] = 0; mapa["4C"] = 0; mapa["5A"] = 0; mapa["5B"] = 0; mapa["5C"] = 0; int n; cin >> n; for(int i = 0; i < n; i++) { string x; cin >> x; mapa[x] ++; } string x = "1A"; while(x != "5A") { if(mapa[x] == 0) { cout << "NIE"; return 0; } x[1] ++; if(x[1] == 'D') { x[0]++; x[1] = 'A'; } } while(x != "6A") { if(mapa[x] <= 1) { cout << "NIE"; return 0; } x[1] ++; if(x[1] == 'D') { x[0]++; x[1] = 'A'; } } cout << "TAK"; } |