#include<bits/stdc++.h> using namespace std; int l1p[300], l1np[300], l2p[300], l2np[300]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; string S1, S2; cin>>S1>>S2; if(n<=2) { if(S1==S2) cout<<"TAK"; else cout<<"NIE"; return 0; } if(n<4) { string S3=S2; reverse(S2.begin(), S2.end()); if(S1==S3||S1==S2) cout<<"TAK"; else cout<<"NIE"; return 0; } for(int i=0;i<S1.size(); ++i) { if(i%2==0) { l1p[S1[i]]++; l2p[S2[i]]++; } else { l1np[S1[i]]++; l2np[S2[i]]++; } } bool f=1; for(int i=1;i<=300; i++) if(l1p[i]!=l2p[i]||l1np[i]!=l2np[i]) { f=0; } if(f==1) cout<<"TAK"; else cout<<"NIE"; 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 | #include<bits/stdc++.h> using namespace std; int l1p[300], l1np[300], l2p[300], l2np[300]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; string S1, S2; cin>>S1>>S2; if(n<=2) { if(S1==S2) cout<<"TAK"; else cout<<"NIE"; return 0; } if(n<4) { string S3=S2; reverse(S2.begin(), S2.end()); if(S1==S3||S1==S2) cout<<"TAK"; else cout<<"NIE"; return 0; } for(int i=0;i<S1.size(); ++i) { if(i%2==0) { l1p[S1[i]]++; l2p[S2[i]]++; } else { l1np[S1[i]]++; l2np[S2[i]]++; } } bool f=1; for(int i=1;i<=300; i++) if(l1p[i]!=l2p[i]||l1np[i]!=l2np[i]) { f=0; } if(f==1) cout<<"TAK"; else cout<<"NIE"; return 0; } |