#include<cstdio> #include<vector> #include<algorithm> #include<cstring> int main() { int n; scanf("%d", &n); char p1[n+1], p2[n+1]; scanf("%s\n", p1); scanf("%s\n", p2); std::vector<char> p11, p12, p21, p22; for (int i = 0; i < n; ++i) { if (i%2) { p11.emplace_back(p1[i]); p21.emplace_back(p2[i]); } else { p12.emplace_back(p1[i]); p22.emplace_back(p2[i]); } } std::sort(p11.begin(), p11.end()); std::sort(p12.begin(), p12.end()); std::sort(p21.begin(), p21.end()); std::sort(p22.begin(), p22.end()); if (p11 == p21 && p12 == p22) puts("TAK"); else puts("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 | #include<cstdio> #include<vector> #include<algorithm> #include<cstring> int main() { int n; scanf("%d", &n); char p1[n+1], p2[n+1]; scanf("%s\n", p1); scanf("%s\n", p2); std::vector<char> p11, p12, p21, p22; for (int i = 0; i < n; ++i) { if (i%2) { p11.emplace_back(p1[i]); p21.emplace_back(p2[i]); } else { p12.emplace_back(p1[i]); p22.emplace_back(p2[i]); } } std::sort(p11.begin(), p11.end()); std::sort(p12.begin(), p12.end()); std::sort(p21.begin(), p21.end()); std::sort(p22.begin(), p22.end()); if (p11 == p21 && p12 == p22) puts("TAK"); else puts("NIE"); return 0; } |