#include<bits/stdc++.h> using namespace std; #define rep(a, b) for(int a = 0; a < (b); ++a) int lx[26][2], ly[26][2]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; string x, y; cin >> n >> x >> y; rep(i, n) { ++lx[x[i]-'a'][i%2]; ++ly[y[i]-'a'][i%2]; } bool t=true; rep(i, 26) { if(lx[i][0]!=ly[i][0] || lx[i][1]!=ly[i][1]) t=false; } if(t) cout << "TAK"; else cout << "NIE"; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include<bits/stdc++.h> using namespace std; #define rep(a, b) for(int a = 0; a < (b); ++a) int lx[26][2], ly[26][2]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; string x, y; cin >> n >> x >> y; rep(i, n) { ++lx[x[i]-'a'][i%2]; ++ly[y[i]-'a'][i%2]; } bool t=true; rep(i, 26) { if(lx[i][0]!=ly[i][0] || lx[i][1]!=ly[i][1]) t=false; } if(t) cout << "TAK"; else cout << "NIE"; } |