#include<bits/stdc++.h> using namespace std; #define MAXN 300007 int letter_parity[27][2], n; char taba[MAXN], tabb[MAXN]; int main(){ scanf("%d", &n); scanf("%s%s", taba, tabb); for(int i = 0; i < n; i++){ letter_parity[taba[i] - 'a'][i%2]++; letter_parity[tabb[i] - 'a'][i%2]--; } // this is def. necessary, but is it sufficient? for(int i = 0; i < 27; i++){ for(int p = 0; p < 2; p++){ if (letter_parity[i][p] != 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 19 20 21 22 23 24 25 26 27 28 29 | #include<bits/stdc++.h> using namespace std; #define MAXN 300007 int letter_parity[27][2], n; char taba[MAXN], tabb[MAXN]; int main(){ scanf("%d", &n); scanf("%s%s", taba, tabb); for(int i = 0; i < n; i++){ letter_parity[taba[i] - 'a'][i%2]++; letter_parity[tabb[i] - 'a'][i%2]--; } // this is def. necessary, but is it sufficient? for(int i = 0; i < 27; i++){ for(int p = 0; p < 2; p++){ if (letter_parity[i][p] != 0){ printf("NIE\n"); return 0; } } } printf("TAK\n"); } |