#include<list> #include<iostream> #include<string> #include<algorithm> #include<iterator> using namespace std; void fillList(string toFill[], list<string> &x) { for (int i = 0; i < 18; i++) { x.push_back(toFill[i]); } } bool remFromList(int n, list<string> &x) { if (n < 18) return false; int i = 0; string toRem; for (i; i < 18; i++) { cin >> toRem; auto it = find(begin(x), end(x), toRem); if (it != end(x)) x.erase(it); } if (x.empty()) return true; for (i; i < n; i++) { cin >> toRem; auto it = find(begin(x), end(x), toRem); if (it != end(x)) x.erase(it); if (x.empty()) return true; } return false; } int main() { string tasksPossible[18] = {"1A", "1B", "1C", "2A", "2B", "2C", "3A", "3B", "3C", "4A", "4B", "4C", "5A", "5B", "5C", "5A", "5B", "5C"}; list<string> tasks; fillList(tasksPossible, tasks); int n; cin >> n; if (remFromList(n, tasks)) { 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 | #include<list> #include<iostream> #include<string> #include<algorithm> #include<iterator> using namespace std; void fillList(string toFill[], list<string> &x) { for (int i = 0; i < 18; i++) { x.push_back(toFill[i]); } } bool remFromList(int n, list<string> &x) { if (n < 18) return false; int i = 0; string toRem; for (i; i < 18; i++) { cin >> toRem; auto it = find(begin(x), end(x), toRem); if (it != end(x)) x.erase(it); } if (x.empty()) return true; for (i; i < n; i++) { cin >> toRem; auto it = find(begin(x), end(x), toRem); if (it != end(x)) x.erase(it); if (x.empty()) return true; } return false; } int main() { string tasksPossible[18] = {"1A", "1B", "1C", "2A", "2B", "2C", "3A", "3B", "3C", "4A", "4B", "4C", "5A", "5B", "5C", "5A", "5B", "5C"}; list<string> tasks; fillList(tasksPossible, tasks); int n; cin >> n; if (remFromList(n, tasks)) { cout << "TAK"; } else { cout << "NIE"; } return 0; } |