#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
string s, t;
cin >> s >> t;
string s1, t1, s2, t2;
for(int i = 0; i < n; i += 2){
s1 += s[i];
t1 += t[i];
}
for(int i = 1; i < n; i += 2){
s2 += s[i];
t2 += t[i];
}
sort(s1.begin(), s1.end());
sort(t1.begin(), t1.end());
sort(s2.begin(), s2.end());
sort(t2.begin(), t2.end());
cout << (s1 == t1 && s2 == t2 ? "TAK" : "NIE");
}
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 | #include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; string s, t; cin >> s >> t; string s1, t1, s2, t2; for(int i = 0; i < n; i += 2){ s1 += s[i]; t1 += t[i]; } for(int i = 1; i < n; i += 2){ s2 += s[i]; t2 += t[i]; } sort(s1.begin(), s1.end()); sort(t1.begin(), t1.end()); sort(s2.begin(), s2.end()); sort(t2.begin(), t2.end()); cout << (s1 == t1 && s2 == t2 ? "TAK" : "NIE"); } |
English