#include <cstdio> #include <cstdlib> using namespace std; #define MAXN 300005 int n; int cntA[26][2]; int cntB[26][2]; char A[MAXN]; char B[MAXN]; int main() { int i; scanf("%d%s%s", &n, A, B); for (i = 0; i < n; i++) { cntA[A[i]-'a'][i&1]++; cntB[B[i]-'a'][i&1]++; } for (i = 0; i < 26; i++) { if (cntA[i][0] != cntB[i][0] || cntA[i][1] != cntB[i][1]) { 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 | #include <cstdio> #include <cstdlib> using namespace std; #define MAXN 300005 int n; int cntA[26][2]; int cntB[26][2]; char A[MAXN]; char B[MAXN]; int main() { int i; scanf("%d%s%s", &n, A, B); for (i = 0; i < n; i++) { cntA[A[i]-'a'][i&1]++; cntB[B[i]-'a'][i&1]++; } for (i = 0; i < 26; i++) { if (cntA[i][0] != cntB[i][0] || cntA[i][1] != cntB[i][1]) { printf("NIE\n"); return 0; } } printf("TAK\n"); return 0; } |