#include <bits/stdc++.h> using namespace std; int main() { int n; string s[2]; cin >> n; cin >> s[0] >> s[1]; vector<char> v[2][2]; for (int i = 0; i <= 1; i++) for (int j = 0; j < n; j++) v[i][j % 2].push_back(s[i][j]); for (int i = 0; i <= 1; i++) for (int p = 0; p <= 1; p++) sort(v[i][p].begin(),v[i][p].end()); cout << ((v[0][0] == v[1][0] && v[0][1] == v[1][1]) ? "TAK" : "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 | #include <bits/stdc++.h> using namespace std; int main() { int n; string s[2]; cin >> n; cin >> s[0] >> s[1]; vector<char> v[2][2]; for (int i = 0; i <= 1; i++) for (int j = 0; j < n; j++) v[i][j % 2].push_back(s[i][j]); for (int i = 0; i <= 1; i++) for (int p = 0; p <= 1; p++) sort(v[i][p].begin(),v[i][p].end()); cout << ((v[0][0] == v[1][0] && v[0][1] == v[1][1]) ? "TAK" : "NIE") << "\n"; return 0; } |