#include <bits/stdc++.h> using namespace std; string z[2]; int n; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>n; cin>>z[0]>>z[1]; string pierw[2], drug[2]; for(int i = 0; i < n; ++i) { pierw[i%2] += z[0][i]; drug[i%2] += z[1][i]; } sort(pierw[0].begin(), pierw[0].end()); sort(pierw[1].begin(), pierw[1].end()); sort(drug[0].begin(), drug[0].end()); sort(drug[1].begin(), drug[1].end()); //cout<<pierw[0]<<" "<<pierw[1]<<"\n"; //cat cout<<drug[0]<<" "<<drug[1]<<"\n"; if(pierw[0] == drug[0] && pierw[1] == drug[1]) { cout<<"TAK\n"; } else { cout<<"NIE\n"; } 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 | #include <bits/stdc++.h> using namespace std; string z[2]; int n; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>n; cin>>z[0]>>z[1]; string pierw[2], drug[2]; for(int i = 0; i < n; ++i) { pierw[i%2] += z[0][i]; drug[i%2] += z[1][i]; } sort(pierw[0].begin(), pierw[0].end()); sort(pierw[1].begin(), pierw[1].end()); sort(drug[0].begin(), drug[0].end()); sort(drug[1].begin(), drug[1].end()); //cout<<pierw[0]<<" "<<pierw[1]<<"\n"; //cat cout<<drug[0]<<" "<<drug[1]<<"\n"; if(pierw[0] == drug[0] && pierw[1] == drug[1]) { cout<<"TAK\n"; } else { cout<<"NIE\n"; } return 0; } |