#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ST first
#define ND second
#define PB push_back
#define SIZE(a) ((int)a.size())
template<class T>
ostream& operator<<(ostream &stream, vector<T> &v) {
stream << "[";
for(auto elem : v) {
stream << elem << ", ";
}
stream << "]";
return stream;
}
int main() {
ios_base::sync_with_stdio(0);
int n;
string a, b;
cin >> n >> a >> b;
vector<char> a1, a2, b1, b2;
for(int i=0; i < n; i++) {
if(i%2 == 0) {
a1.PB(a[i]);
} else {
a2.PB(a[i]);
}
}
for(int i=0; i < n; i++) {
if(i%2 == 0) {
b1.PB(b[i]);
} else {
b2.PB(b[i]);
}
}
sort(a1.begin(), a1.end());
sort(b1.begin(), b1.end());
sort(a2.begin(), a2.end());
sort(b2.begin(), b2.end());
if(a1 == b1 && a2 == b2) {
cout << "TAK\n";
} else {
cout << "NIE\n";
}
}
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 | #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define ST first #define ND second #define PB push_back #define SIZE(a) ((int)a.size()) template<class T> ostream& operator<<(ostream &stream, vector<T> &v) { stream << "["; for(auto elem : v) { stream << elem << ", "; } stream << "]"; return stream; } int main() { ios_base::sync_with_stdio(0); int n; string a, b; cin >> n >> a >> b; vector<char> a1, a2, b1, b2; for(int i=0; i < n; i++) { if(i%2 == 0) { a1.PB(a[i]); } else { a2.PB(a[i]); } } for(int i=0; i < n; i++) { if(i%2 == 0) { b1.PB(b[i]); } else { b2.PB(b[i]); } } sort(a1.begin(), a1.end()); sort(b1.begin(), b1.end()); sort(a2.begin(), a2.end()); sort(b2.begin(), b2.end()); if(a1 == b1 && a2 == b2) { cout << "TAK\n"; } else { cout << "NIE\n"; } } |
English