#include<iostream> #include <unordered_map> #include <string> using namespace std; int main() { unordered_map<string, int> hmap = { make_pair("1A",1), make_pair("1B",1), make_pair("1C",1), make_pair("2A",1), make_pair("2B",1), make_pair("2C",1), make_pair("3A",1), make_pair("3B",1), make_pair("3C",1), make_pair("4A",1), make_pair("4B",1), make_pair("4C",1), make_pair("5A",2), make_pair("5B",2), make_pair("5C",2) }; unordered_map<string,int> hmap1; int n; cin >> n; for(int i=0;i<n;i++) { string s; cin >> s; hmap1[s]++; } bool flag = 1; for (auto p : hmap) if (hmap1[p.first] < hmap[p.first]) { flag = 0; break; } if (flag) cout << "TAK"; else cout << "NIE"; }
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 | #include<iostream> #include <unordered_map> #include <string> using namespace std; int main() { unordered_map<string, int> hmap = { make_pair("1A",1), make_pair("1B",1), make_pair("1C",1), make_pair("2A",1), make_pair("2B",1), make_pair("2C",1), make_pair("3A",1), make_pair("3B",1), make_pair("3C",1), make_pair("4A",1), make_pair("4B",1), make_pair("4C",1), make_pair("5A",2), make_pair("5B",2), make_pair("5C",2) }; unordered_map<string,int> hmap1; int n; cin >> n; for(int i=0;i<n;i++) { string s; cin >> s; hmap1[s]++; } bool flag = 1; for (auto p : hmap) if (hmap1[p.first] < hmap[p.first]) { flag = 0; break; } if (flag) cout << "TAK"; else cout << "NIE"; } |