#include <bits/stdc++.h>
using namespace std;
int n;
vector < char > a_1, b_1, a_2, b_2;
int main(){
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 0; i < n; ++i)
{
char c;
cin >> c;
if(i % 2){
a_1.push_back(c);
}
else{
b_1.push_back(c);
}
}
for (int i = 0; i < n; ++i)
{
char c;
cin >> c;
if(i % 2){
a_2.push_back(c);
}
else{
b_2.push_back(c);
}
}
sort(a_1.begin(), a_1.end());
sort(a_2.begin(), a_2.end());
sort(b_1.begin(), b_1.end());
sort(b_2.begin(), b_2.end());
for (int i = 0; i < a_1.size(); ++i)
{
if(a_1[i] != a_2[i]){
cout << "NIE" << endl;
return 0;
}
}
for (int i = 0; i < b_1.size(); ++i)
{
if(b_1[i] != b_2[i]){
cout << "NIE" << endl;
return 0;
}
}
cout << "TAK" << endl;
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 51 52 53 54 55 56 57 58 59 60 61 | #include <bits/stdc++.h> using namespace std; int n; vector < char > a_1, b_1, a_2, b_2; int main(){ cin.tie(0); cout.tie(0); cin >> n; for (int i = 0; i < n; ++i) { char c; cin >> c; if(i % 2){ a_1.push_back(c); } else{ b_1.push_back(c); } } for (int i = 0; i < n; ++i) { char c; cin >> c; if(i % 2){ a_2.push_back(c); } else{ b_2.push_back(c); } } sort(a_1.begin(), a_1.end()); sort(a_2.begin(), a_2.end()); sort(b_1.begin(), b_1.end()); sort(b_2.begin(), b_2.end()); for (int i = 0; i < a_1.size(); ++i) { if(a_1[i] != a_2[i]){ cout << "NIE" << endl; return 0; } } for (int i = 0; i < b_1.size(); ++i) { if(b_1[i] != b_2[i]){ cout << "NIE" << endl; return 0; } } cout << "TAK" << endl; return 0; } |
English