#include <cstdio>
#include <vector>
using namespace std;
int n;
char s1[300000 + 9];
char s2[300000 + 9];
int cnt1[26];
int cnt2[26];
int cnt3[26];
int cnt4[26];
bool check() {
for (int i=0; i<26; ++i) if (cnt1[i] != cnt2[i]) return false;
for (int i=0; i<26; ++i) if (cnt3[i] != cnt4[i]) return false;
return true;
}
int main() {
for (int i=0; i<26; ++i) cnt1[i] = cnt2[i] = 0;
scanf("%d%s%s", &n, s1, s2);
for (int i=0; i<n; i+=2) {
++cnt1[s1[i] - 'a'];
++cnt2[s2[i] - 'a'];
}
for (int i=1; i<n; i+=2) {
++cnt3[s1[i] - 'a'];
++cnt4[s2[i] - 'a'];
}
bool res = check();
printf(res ? "TAK\n" : "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 <cstdio> #include <vector> using namespace std; int n; char s1[300000 + 9]; char s2[300000 + 9]; int cnt1[26]; int cnt2[26]; int cnt3[26]; int cnt4[26]; bool check() { for (int i=0; i<26; ++i) if (cnt1[i] != cnt2[i]) return false; for (int i=0; i<26; ++i) if (cnt3[i] != cnt4[i]) return false; return true; } int main() { for (int i=0; i<26; ++i) cnt1[i] = cnt2[i] = 0; scanf("%d%s%s", &n, s1, s2); for (int i=0; i<n; i+=2) { ++cnt1[s1[i] - 'a']; ++cnt2[s2[i] - 'a']; } for (int i=1; i<n; i+=2) { ++cnt3[s1[i] - 'a']; ++cnt4[s2[i] - 'a']; } bool res = check(); printf(res ? "TAK\n" : "NIE\n"); return 0; } |
English