#include <cstdio> #include <cstring> char s[300001], t[300001]; int tabs[26][2], tabt[26][2]; int main() { int n; memset(tabs,0,sizeof(tabs)); memset(tabt,0,sizeof(tabt)); scanf("%d", &n); scanf("%s", s); scanf("%s", t); for (int i = 0; i < n; i++) { int x = s[i] - 'a'; tabs[x][i % 2]++; x = t[i] - 'a'; tabt[x][i % 2]++; } bool ok = true; for (int i = 0; i < 26; i++) { for (int j = 0; j < 2; j++) { if (tabs[i][j] != tabt[i][j]) ok = false; } } if (ok) { 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 40 41 42 43 44 45 46 | #include <cstdio> #include <cstring> char s[300001], t[300001]; int tabs[26][2], tabt[26][2]; int main() { int n; memset(tabs,0,sizeof(tabs)); memset(tabt,0,sizeof(tabt)); scanf("%d", &n); scanf("%s", s); scanf("%s", t); for (int i = 0; i < n; i++) { int x = s[i] - 'a'; tabs[x][i % 2]++; x = t[i] - 'a'; tabt[x][i % 2]++; } bool ok = true; for (int i = 0; i < 26; i++) { for (int j = 0; j < 2; j++) { if (tabs[i][j] != tabt[i][j]) ok = false; } } if (ok) { printf("TAK\n"); } else { printf("NIE\n"); } return 0; } |