#include <bits/stdc++.h> using namespace std; #define LL long long #define ULL unsigned LL #define LD long double int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; string s[2]; cin>>s[0]>>s[1]; vector<char> V[2][2]; for(int t=0; t<2; t++) { for(int i=0; i<n; i++) { V[t][i%2].push_back(s[t][i]); } } for(int i=0; i<2; i++) { for(int j=0; j<2; j++) sort(V[i][j].begin(), V[i][j].end()); } bool ok = (V[0][0] == V[1][0] && V[0][1] == V[1][1]); cout<<(ok ? "TAK" : "NIE"); }
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 | #include <bits/stdc++.h> using namespace std; #define LL long long #define ULL unsigned LL #define LD long double int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; string s[2]; cin>>s[0]>>s[1]; vector<char> V[2][2]; for(int t=0; t<2; t++) { for(int i=0; i<n; i++) { V[t][i%2].push_back(s[t][i]); } } for(int i=0; i<2; i++) { for(int j=0; j<2; j++) sort(V[i][j].begin(), V[i][j].end()); } bool ok = (V[0][0] == V[1][0] && V[0][1] == V[1][1]); cout<<(ok ? "TAK" : "NIE"); } |