#include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <string> #include <map> #include <unordered_map> #include <set> #include <unordered_set> #include <queue> #include <deque> using namespace std; bool solve(int &n, string &a, string &b) { unordered_multiset<char> evena, evenb, odda, oddb; for (int i = 0; i < n; i++) { if (i % 2) { odda.insert(a[i]); oddb.insert(b[i]); } else { evena.insert(a[i]); evenb.insert(b[i]); } } return (evena == evenb) && (odda == oddb); } int main() { ios_base::sync_with_stdio(0); int n; string a, b; cin >> n >> a >> b; if (solve(n, a, b)) cout << "TAK\n"; else cout << "NIE\n"; 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 | #include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <string> #include <map> #include <unordered_map> #include <set> #include <unordered_set> #include <queue> #include <deque> using namespace std; bool solve(int &n, string &a, string &b) { unordered_multiset<char> evena, evenb, odda, oddb; for (int i = 0; i < n; i++) { if (i % 2) { odda.insert(a[i]); oddb.insert(b[i]); } else { evena.insert(a[i]); evenb.insert(b[i]); } } return (evena == evenb) && (odda == oddb); } int main() { ios_base::sync_with_stdio(0); int n; string a, b; cin >> n >> a >> b; if (solve(n, a, b)) cout << "TAK\n"; else cout << "NIE\n"; return 0; } |