#include <bits/stdc++.h>
using namespace std;
int n;
string l, l1, d, d1;
int main(){
ios_base::sync_with_stdio(0);
cin.tie();
cout.tie();
cin >> n;
cin >> l;
l1 = l;
sort(l1.begin(), l1.end());
cin >> d;
d1 = d;
sort(d1.begin(), d1.end());
if (l1 == d1){
if (n%2 == 1) {
for (int i = 1; i < n/2; i++) {
l.erase(i, 1);
d.erase(i, 1);
}
}
else {
for (int i = 1; i < n/2 +1; i++) {
l.erase(i, 1);
d.erase(i, 1);
}
}
sort(l.begin(), l.end());
sort(d.begin(), d.end());
if (l == d)
cout << "TAK";
else
cout << "NIE";
}
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 38 39 40 41 42 43 44 45 46 47 48 49 50 | #include <bits/stdc++.h> using namespace std; int n; string l, l1, d, d1; int main(){ ios_base::sync_with_stdio(0); cin.tie(); cout.tie(); cin >> n; cin >> l; l1 = l; sort(l1.begin(), l1.end()); cin >> d; d1 = d; sort(d1.begin(), d1.end()); if (l1 == d1){ if (n%2 == 1) { for (int i = 1; i < n/2; i++) { l.erase(i, 1); d.erase(i, 1); } } else { for (int i = 1; i < n/2 +1; i++) { l.erase(i, 1); d.erase(i, 1); } } sort(l.begin(), l.end()); sort(d.begin(), d.end()); if (l == d) cout << "TAK"; else cout << "NIE"; } else cout << "NIE"; return 0; } |
English