#include <iostream> #include <vector> #include <unordered_map> using namespace std; int main(){ int n; cin >> n; string tab[n]; string ans = "TAK"; unordered_map<string, int> map; for(int i=1;i<=5;i++){ map[to_string(i) + "A"] = 0; map[to_string(i) + "B"] = 0; map[to_string(i) + "C"] = 0; } for(int i=0; i<n; i++){ cin >> tab[i]; map[tab[i]]++; } if(n < 18){ ans = "NIE"; } for(auto it=map.begin(); it !=map.end(); it++){ if(it ->first[0] - '0'< 5){ it->second-=1; } else{ it->second -=2; } //cout<<it->first<<": "<<it->second<<"\n"; if(it->second) n-=it->second; if(it->second < 0 || n<18){ ans = "NIE"; break; } } cout<<ans; 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 | #include <iostream> #include <vector> #include <unordered_map> using namespace std; int main(){ int n; cin >> n; string tab[n]; string ans = "TAK"; unordered_map<string, int> map; for(int i=1;i<=5;i++){ map[to_string(i) + "A"] = 0; map[to_string(i) + "B"] = 0; map[to_string(i) + "C"] = 0; } for(int i=0; i<n; i++){ cin >> tab[i]; map[tab[i]]++; } if(n < 18){ ans = "NIE"; } for(auto it=map.begin(); it !=map.end(); it++){ if(it ->first[0] - '0'< 5){ it->second-=1; } else{ it->second -=2; } //cout<<it->first<<": "<<it->second<<"\n"; if(it->second) n-=it->second; if(it->second < 0 || n<18){ ans = "NIE"; break; } } cout<<ans; return 0; } |