#include <iostream> #include <cstring> #include <algorithm> using namespace std; int main() { ios_base::sync_with_stdio(false); int n; string s1, s2; string sn1, sp1, sn2, sp2; cin >> n >> s1 >> s2; for (int i=0; n>i; i++){ (i%2) ? sp1 += s1[i] : sn1 += s1[i]; (i%2) ? sp2 += s2[i] : sn2 += s2[i]; } sort(sp1.begin(), sp1.end()); sort(sp2.begin(), sp2.end()); sort(sn1.begin(), sn1.end()); sort(sn2.begin(), sn2.end()); (sn1.compare(sn2) == 0 && sp1.compare(sp2) == 0) ? cout << "TAK\n" : 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 | #include <iostream> #include <cstring> #include <algorithm> using namespace std; int main() { ios_base::sync_with_stdio(false); int n; string s1, s2; string sn1, sp1, sn2, sp2; cin >> n >> s1 >> s2; for (int i=0; n>i; i++){ (i%2) ? sp1 += s1[i] : sn1 += s1[i]; (i%2) ? sp2 += s2[i] : sn2 += s2[i]; } sort(sp1.begin(), sp1.end()); sort(sp2.begin(), sp2.end()); sort(sn1.begin(), sn1.end()); sort(sn2.begin(), sn2.end()); (sn1.compare(sn2) == 0 && sp1.compare(sp2) == 0) ? cout << "TAK\n" : cout << "NIE\n"; return 0; } |