#include<bits/stdc++.h> using namespace std; string jeden,dwa,s1,s2,z1,z2; int n; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; cin >> jeden >> dwa; for(int i=0;i<n; i+=2){ s1+=jeden[i]; z1+=dwa[i]; } for(int i=1;i<n;i+=2){ s2+=jeden[i]; z2+=dwa[i]; } sort(s1.begin(),s1.end()); sort(s2.begin(),s2.end()); sort(z1.begin(),z1.end()); sort(z2.begin(),z2.end()); //cout << s1<<" "<< s2<<" "<< z1<<" "<<z2; if(s1==z1 and s2==z2){ cout << "TAK"; } else cout << "NIE"; return 0; }
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 30 31 32 33 34 35 36 37 | #include<bits/stdc++.h> using namespace std; string jeden,dwa,s1,s2,z1,z2; int n; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; cin >> jeden >> dwa; for(int i=0;i<n; i+=2){ s1+=jeden[i]; z1+=dwa[i]; } for(int i=1;i<n;i+=2){ s2+=jeden[i]; z2+=dwa[i]; } sort(s1.begin(),s1.end()); sort(s2.begin(),s2.end()); sort(z1.begin(),z1.end()); sort(z2.begin(),z2.end()); //cout << s1<<" "<< s2<<" "<< z1<<" "<<z2; if(s1==z1 and s2==z2){ cout << "TAK"; } else cout << "NIE"; return 0; } |