#include <iostream> int n; char sa[300010], sb[300010]; int main() { scanf("%d", &n); scanf("%s", sa); scanf("%s", sb); int occurences_odd[26] = {0}; int occurences_even[26] = {0}; for (int i = 0; i < n; ++i) { if (i % 2 == 0) { occurences_even[sa[i] - 'a']++; occurences_even[sb[i] - 'a']--; } else { occurences_odd[sa[i] - 'a']++; occurences_odd[sb[i] - 'a']--; } } for (int i = 0; i < 26; ++i) { if (occurences_even[i] != 0 || occurences_odd[i] != 0) { printf("NIE\n"); return 0; } } printf("TAK\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 | #include <iostream> int n; char sa[300010], sb[300010]; int main() { scanf("%d", &n); scanf("%s", sa); scanf("%s", sb); int occurences_odd[26] = {0}; int occurences_even[26] = {0}; for (int i = 0; i < n; ++i) { if (i % 2 == 0) { occurences_even[sa[i] - 'a']++; occurences_even[sb[i] - 'a']--; } else { occurences_odd[sa[i] - 'a']++; occurences_odd[sb[i] - 'a']--; } } for (int i = 0; i < 26; ++i) { if (occurences_even[i] != 0 || occurences_odd[i] != 0) { printf("NIE\n"); return 0; } } printf("TAK\n"); return 0; } |