#include<bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> countEven1(26), countOdd1(26);
vector<int> countEven2(26), countOdd2(26);
string s1, s2;
cin >> s1 >> s2;
for(int i = 0; i < n; i += 2) {
countEven1[s1[i] - 'a']++;
countEven2[s2[i] - 'a']++;
}
for(int i = 1; i < n; i += 2) {
countOdd1[s1[i] - 'a']++;
countOdd2[s2[i] - 'a']++;
}
for(int i = 0; i < 26; i++) {
if(countEven1[i] != countEven2[i] || countOdd1[i] != countOdd2[i]) {
cout << "NIE" << endl;
return 0;
}
}
cout << "TAK" << endl;
}
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; int main() { int n; cin >> n; vector<int> countEven1(26), countOdd1(26); vector<int> countEven2(26), countOdd2(26); string s1, s2; cin >> s1 >> s2; for(int i = 0; i < n; i += 2) { countEven1[s1[i] - 'a']++; countEven2[s2[i] - 'a']++; } for(int i = 1; i < n; i += 2) { countOdd1[s1[i] - 'a']++; countOdd2[s2[i] - 'a']++; } for(int i = 0; i < 26; i++) { if(countEven1[i] != countEven2[i] || countOdd1[i] != countOdd2[i]) { cout << "NIE" << endl; return 0; } } cout << "TAK" << endl; } |
English