#include <bits/stdc++.h> int main() { std::ios_base::sync_with_stdio(0); std::cin.tie(NULL); int n; std::cin >> n; std::string a, b; std::cin >> a >> b; std::string A, B, C, D; A = B = C = D = ""; for (int i = 0; i < n; i += 2) { A += a[i]; B += b[i]; } for (int i = 1; i < n; i += 2) { C += a[i]; D += b[i]; } std::sort(A.begin(), A.end()); std::sort(B.begin(), B.end()); std::sort(C.begin(), C.end()); std::sort(D.begin(), D.end()); if (A == B && C == D) { std::cout << "TAK\n"; } else { std::cout << "NIE\n"; } }
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 | #include <bits/stdc++.h> int main() { std::ios_base::sync_with_stdio(0); std::cin.tie(NULL); int n; std::cin >> n; std::string a, b; std::cin >> a >> b; std::string A, B, C, D; A = B = C = D = ""; for (int i = 0; i < n; i += 2) { A += a[i]; B += b[i]; } for (int i = 1; i < n; i += 2) { C += a[i]; D += b[i]; } std::sort(A.begin(), A.end()); std::sort(B.begin(), B.end()); std::sort(C.begin(), C.end()); std::sort(D.begin(), D.end()); if (A == B && C == D) { std::cout << "TAK\n"; } else { std::cout << "NIE\n"; } } |