#include <bits/stdc++.h> using namespace std; int n; string s1, s2; void solve() { cin >> n; cin >> s1 >> s2; vector<char> v1, v2; vector<char> v3, v4; for (int i = 0; i < s1.size(); i++) { if (i%2) v1.push_back(s1[i]); else v2.push_back(s1[i]); } for (int i = 0; i < s2.size(); i++) { if (i%2) v3.push_back(s2[i]); else v4.push_back(s2[i]); } sort(v1.begin(), v1.end()); sort(v2.begin(), v2.end()); sort(v3.begin(), v3.end()); sort(v4.begin(), v4.end()); if (v1 == v3 && v2 == v4) cout << "TAK\n"; else cout << "NIE\n"; } int main() { ios_base::sync_with_stdio(0);cin.tie(0); int tt = 1; while(tt--) { solve(); } }
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 | #include <bits/stdc++.h> using namespace std; int n; string s1, s2; void solve() { cin >> n; cin >> s1 >> s2; vector<char> v1, v2; vector<char> v3, v4; for (int i = 0; i < s1.size(); i++) { if (i%2) v1.push_back(s1[i]); else v2.push_back(s1[i]); } for (int i = 0; i < s2.size(); i++) { if (i%2) v3.push_back(s2[i]); else v4.push_back(s2[i]); } sort(v1.begin(), v1.end()); sort(v2.begin(), v2.end()); sort(v3.begin(), v3.end()); sort(v4.begin(), v4.end()); if (v1 == v3 && v2 == v4) cout << "TAK\n"; else cout << "NIE\n"; } int main() { ios_base::sync_with_stdio(0);cin.tie(0); int tt = 1; while(tt--) { solve(); } } |