#include <iostream> #include <algorithm> using namespace std; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; string toys1, toys2; cin >> toys1 >> toys2; string toys1_even, toys1_odd; string toys2_even, toys2_odd; for(int i = 0; i < n; i++) { if(i%2 == 0) { toys1_even += toys1[i]; toys2_even += toys2[i]; } else { toys1_odd += toys1[i]; toys2_odd += toys2[i]; } } sort(toys1_even.begin(), toys1_even.end()); sort(toys2_even.begin(), toys2_even.end()); sort(toys1_odd.begin(), toys1_odd.end()); sort(toys2_odd.begin(), toys2_odd.end()); if(toys1_even == toys2_even and toys1_odd == toys2_odd) cout<<"TAK"<<endl; else cout<<"NIE"<<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 30 31 32 33 34 35 36 37 38 39 40 41 | #include <iostream> #include <algorithm> using namespace std; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; string toys1, toys2; cin >> toys1 >> toys2; string toys1_even, toys1_odd; string toys2_even, toys2_odd; for(int i = 0; i < n; i++) { if(i%2 == 0) { toys1_even += toys1[i]; toys2_even += toys2[i]; } else { toys1_odd += toys1[i]; toys2_odd += toys2[i]; } } sort(toys1_even.begin(), toys1_even.end()); sort(toys2_even.begin(), toys2_even.end()); sort(toys1_odd.begin(), toys1_odd.end()); sort(toys2_odd.begin(), toys2_odd.end()); if(toys1_even == toys2_even and toys1_odd == toys2_odd) cout<<"TAK"<<endl; else cout<<"NIE"<<endl; } |