#include <bits/stdc++.h> using namespace std; int main() { std::map<char, int> bajt[2], bit[2]; int n; cin >> n; for (int i = 0; i < n; i++) { char x; cin >> x; bit[i % 2][x]++; } for (int i = 0; i < n; i++) { char x; cin >> x; bajt[i % 2][x]++; } bool impossible = false; for (const auto &it : bit[0]) { if (bajt[0][it.first] != it.second) { impossible = true; break; } } if (!impossible) { for (const auto &it : bit[1]) { if (bajt[1][it.first] != it.second) { impossible = true; break; } } } cout << (impossible ? "NIE" : "TAK") << endl; 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 | #include <bits/stdc++.h> using namespace std; int main() { std::map<char, int> bajt[2], bit[2]; int n; cin >> n; for (int i = 0; i < n; i++) { char x; cin >> x; bit[i % 2][x]++; } for (int i = 0; i < n; i++) { char x; cin >> x; bajt[i % 2][x]++; } bool impossible = false; for (const auto &it : bit[0]) { if (bajt[0][it.first] != it.second) { impossible = true; break; } } if (!impossible) { for (const auto &it : bit[1]) { if (bajt[1][it.first] != it.second) { impossible = true; break; } } } cout << (impossible ? "NIE" : "TAK") << endl; return 0; } |