#include <bits/stdc++.h> using namespace std; int n; string s1, s2; int cnt[2][30]; int main() { ios_base::sync_with_stdio(0); cin >> n >> s1 >> s2; for(int i = 0; i < n; i++) { cnt[i % 2][s1[i] - 'a']++; cnt[i % 2][s2[i] - 'a']--; } for(int i = 0; i < 2; i++) { for(int j = 'a'; j <= 'z'; j++) { if(cnt[i][j - 'a']) { cout << "NIE\n"; return 0; } } } cout << "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 | #include <bits/stdc++.h> using namespace std; int n; string s1, s2; int cnt[2][30]; int main() { ios_base::sync_with_stdio(0); cin >> n >> s1 >> s2; for(int i = 0; i < n; i++) { cnt[i % 2][s1[i] - 'a']++; cnt[i % 2][s2[i] - 'a']--; } for(int i = 0; i < 2; i++) { for(int j = 'a'; j <= 'z'; j++) { if(cnt[i][j - 'a']) { cout << "NIE\n"; return 0; } } } cout << "TAK\n"; } |