#include<cstdio> int n; char * s1; char * s2; int c1[2]['z' - 'a' + 1]; int c2[2]['z' - 'a' + 1]; void input() { scanf("%d", &n); s1 = new char[n]; s2 = new char[n]; scanf("%s", s1); scanf("%s", s2); } void count() { for (int i = 0; i < n; ++i) { c1[i % 2][s1[i] - 'a']++; c2[i % 2][s2[i] - 'a']++; } } bool possible() { for (int i = 0; i < 2; ++i) { for (int j = 0; j < 'z' - 'a' + 1; ++j) { // printf("%d %d %d %d\n", i, j, c1[i][j], c2[i][j]); if (c1[i][j] != c2[i][j]) { return false; } } } return true; } int main() { input(); count(); printf(possible() ? "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 36 37 38 39 40 41 42 | #include<cstdio> int n; char * s1; char * s2; int c1[2]['z' - 'a' + 1]; int c2[2]['z' - 'a' + 1]; void input() { scanf("%d", &n); s1 = new char[n]; s2 = new char[n]; scanf("%s", s1); scanf("%s", s2); } void count() { for (int i = 0; i < n; ++i) { c1[i % 2][s1[i] - 'a']++; c2[i % 2][s2[i] - 'a']++; } } bool possible() { for (int i = 0; i < 2; ++i) { for (int j = 0; j < 'z' - 'a' + 1; ++j) { // printf("%d %d %d %d\n", i, j, c1[i][j], c2[i][j]); if (c1[i][j] != c2[i][j]) { return false; } } } return true; } int main() { input(); count(); printf(possible() ? "TAK\n" : "NIE\n"); return 0; } |