#include <iostream> #include <vector> using namespace std; const int l='z'-'a'+1; int main(){ ios_base::sync_with_stdio(0);cin.tie(0); int n; cin>>n; vector<int>ilea;ilea.resize(l*2,0); vector<int>ileb;ileb.resize(l*2,0); char c; for(int i=0;i<n;i++){ cin>>c; ilea[ (c-'a') *((i%2)?1:2) ]++; } for(int i=0;i<n;i++){ cin>>c; ileb[ (c-'a') *((i%2)?1:2) ]++; } if(ilea==ileb)cout<<"TAK\n"; else cout<<"NIE\n"; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <iostream> #include <vector> using namespace std; const int l='z'-'a'+1; int main(){ ios_base::sync_with_stdio(0);cin.tie(0); int n; cin>>n; vector<int>ilea;ilea.resize(l*2,0); vector<int>ileb;ileb.resize(l*2,0); char c; for(int i=0;i<n;i++){ cin>>c; ilea[ (c-'a') *((i%2)?1:2) ]++; } for(int i=0;i<n;i++){ cin>>c; ileb[ (c-'a') *((i%2)?1:2) ]++; } if(ilea==ileb)cout<<"TAK\n"; else cout<<"NIE\n"; } |