#include <bits/stdc++.h> using namespace std; char c1[1000111], c2[1000111]; string p1, p2; int main() { int n; scanf("%d", &n); scanf("%s", c1+1); scanf("%s", c2+1); for (int i = 1; i <= n; i+=2) { p1.push_back(c1[i]); p2.push_back(c2[i]); } sort(p1.begin(), p1.end()); sort(p2.begin(), p2.end()); bool basaur = true; if (p1 != p2) basaur = false; p1.clear(); p2.clear(); for (int i = 2; i <= n; i+=2) { p1.push_back(c1[i]); p2.push_back(c2[i]); } sort(p1.begin(), p1.end()); sort(p2.begin(), p2.end()); if (p1 != p2) basaur = false; if (basaur) printf("TAK\n"); else printf("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 37 38 39 | #include <bits/stdc++.h> using namespace std; char c1[1000111], c2[1000111]; string p1, p2; int main() { int n; scanf("%d", &n); scanf("%s", c1+1); scanf("%s", c2+1); for (int i = 1; i <= n; i+=2) { p1.push_back(c1[i]); p2.push_back(c2[i]); } sort(p1.begin(), p1.end()); sort(p2.begin(), p2.end()); bool basaur = true; if (p1 != p2) basaur = false; p1.clear(); p2.clear(); for (int i = 2; i <= n; i+=2) { p1.push_back(c1[i]); p2.push_back(c2[i]); } sort(p1.begin(), p1.end()); sort(p2.begin(), p2.end()); if (p1 != p2) basaur = false; if (basaur) printf("TAK\n"); else printf("NIE\n"); return 0; } |