#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string parz_wzor, nparz_wzor, parz_cel, nparz_cel; int N; string a, b; cin >> N >> a >> b; if (N <= 2) { if (a == b)cout << "TAK\n"; else cout << "NIE\n"; } else { for(int i = 0; i < N; ++i) { if (i & 1) { parz_wzor += a[i]; parz_cel += b[i]; } else { nparz_cel += a[i]; nparz_wzor += b[i]; } } sort(begin(parz_wzor), end(parz_wzor)); sort(begin(parz_cel), end(parz_cel)); sort(begin(nparz_cel), end(nparz_cel)); sort(begin(nparz_wzor), end(nparz_wzor)); if (parz_wzor == parz_cel && nparz_cel == nparz_wzor) { 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string parz_wzor, nparz_wzor, parz_cel, nparz_cel; int N; string a, b; cin >> N >> a >> b; if (N <= 2) { if (a == b)cout << "TAK\n"; else cout << "NIE\n"; } else { for(int i = 0; i < N; ++i) { if (i & 1) { parz_wzor += a[i]; parz_cel += b[i]; } else { nparz_cel += a[i]; nparz_wzor += b[i]; } } sort(begin(parz_wzor), end(parz_wzor)); sort(begin(parz_cel), end(parz_cel)); sort(begin(nparz_cel), end(nparz_cel)); sort(begin(nparz_wzor), end(nparz_wzor)); if (parz_wzor == parz_cel && nparz_cel == nparz_wzor) { cout << "TAK\n"; } else cout << "NIE\n"; } return 0; } |