#include <iostream> using namespace std; int main() { std::ios::sync_with_stdio(false); cin.tie(0); int n; cin >>n; int tab[2][26]; for (int j=0;j<2;j++) for (int i=0; i<26;i++) tab[j][i]=0; int m=n; while(m-->0){ char c; cin>>c; tab[m%2][c-'a']++; } m=n; while(m-->0){ char c; cin>>c; tab[m%2][c-'a']--; } bool equal = true; for (int j=0;j<2;j++) for (int i=0; i<26;i++) equal = equal && tab[j][i]==0; cout<<(equal?"TAK":"NIE")<<endl; /* int nn = 300000; cout<<nn<<endl; for (int i=0; i<nn;i++) { if (i==3) cout<<'b'; else cout<<'a'; } cout<<endl; for (int i=0; i<nn;i++) { if (i==8) cout<<'b'; else cout<<'a'; } cout<<endl;*/ 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 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 53 54 55 56 57 | #include <iostream> using namespace std; int main() { std::ios::sync_with_stdio(false); cin.tie(0); int n; cin >>n; int tab[2][26]; for (int j=0;j<2;j++) for (int i=0; i<26;i++) tab[j][i]=0; int m=n; while(m-->0){ char c; cin>>c; tab[m%2][c-'a']++; } m=n; while(m-->0){ char c; cin>>c; tab[m%2][c-'a']--; } bool equal = true; for (int j=0;j<2;j++) for (int i=0; i<26;i++) equal = equal && tab[j][i]==0; cout<<(equal?"TAK":"NIE")<<endl; /* int nn = 300000; cout<<nn<<endl; for (int i=0; i<nn;i++) { if (i==3) cout<<'b'; else cout<<'a'; } cout<<endl; for (int i=0; i<nn;i++) { if (i==8) cout<<'b'; else cout<<'a'; } cout<<endl;*/ return 0; } |