#include <cstdio> using namespace std; #define FOR(i,a,b) for(int (i)=(int)(a); (i)!=(int)(b); ++(i)) int n; char S[300001]; int P[2][26]; int main() { scanf("%d", &n); FOR(i,0,26) P[0][i] = P[1][i] = 0; scanf("%s", S); FOR(i,0,n) ++P[i%2][S[i]-'a']; scanf("%s", S); FOR(i,0,n) --P[i%2][S[i]-'a']; FOR(i,0,2) FOR(j,0,26) if (P[i][j] != 0) { printf("NIE\n"); return 0; } printf("TAK\n"); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include <cstdio> using namespace std; #define FOR(i,a,b) for(int (i)=(int)(a); (i)!=(int)(b); ++(i)) int n; char S[300001]; int P[2][26]; int main() { scanf("%d", &n); FOR(i,0,26) P[0][i] = P[1][i] = 0; scanf("%s", S); FOR(i,0,n) ++P[i%2][S[i]-'a']; scanf("%s", S); FOR(i,0,n) --P[i%2][S[i]-'a']; FOR(i,0,2) FOR(j,0,26) if (P[i][j] != 0) { printf("NIE\n"); return 0; } printf("TAK\n"); } |