#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int main() { int n; cin >> n; string s, t; cin >> s >> t; bool ok = true; vector<char> a1, a2, b1, b2; for (int i = 0; i < n; i++) { if (i % 2 == 0) a1.push_back(s[i]); else a2.push_back(s[i]); if (i % 2 == 0) b1.push_back(t[i]); else b2.push_back(t[i]); } sort(a1.begin(), a1.end()); sort(a2.begin(), a2.end()); sort(b1.begin(), b1.end()); sort(b2.begin(), b2.end()); for (int i = 0; i < a1.size(); i++) { if (a1[i] != b1[i]) ok = false; } for (int i = 0; i < a2.size(); i++) { if (a2[i] != b2[i]) ok = false; } if (ok) 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 | #include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int main() { int n; cin >> n; string s, t; cin >> s >> t; bool ok = true; vector<char> a1, a2, b1, b2; for (int i = 0; i < n; i++) { if (i % 2 == 0) a1.push_back(s[i]); else a2.push_back(s[i]); if (i % 2 == 0) b1.push_back(t[i]); else b2.push_back(t[i]); } sort(a1.begin(), a1.end()); sort(a2.begin(), a2.end()); sort(b1.begin(), b1.end()); sort(b2.begin(), b2.end()); for (int i = 0; i < a1.size(); i++) { if (a1[i] != b1[i]) ok = false; } for (int i = 0; i < a2.size(); i++) { if (a2[i] != b2[i]) ok = false; } if (ok) cout << "TAK\n"; else cout << "NIE\n"; return 0; } |