#include <bits/stdc++.h>
using namespace std;
//bool sortbysec(const pair<char,int> &a,
// const pair<char,int> &b)
//{
// return (a.first < b.first);
//}
int main()
{
ios_base::sync_with_stdio(false);
int n;
pair<char,int> tab1[300002];
pair<char,int> tab2[300002];
cin>>n;
for(int i=0;i^n;++i){
cin>>tab1[i].first;
tab1[i].second=i;
//tab2[i].second=i;
}
for(int i=0;i^n;++i){
cin>>tab2[i].first;
tab2[i].second=i;
}
sort(tab1,tab1+n);
sort(tab2,tab2+n);
for(int i=0;i^n;++i){
//cout<<tab1[i].first<<' '<<tab2[i].first<<" "<<tab1[i].second<<' '<<tab2[i].second<<endl;
if(tab1[i].first!=tab2[i].first){
cout<<"NIE";
return 0;
}
}
for(int i=0;i^n;++i){
// cout<<tab1[i].first<<' '<<tab2[i].first<<" "<<tab1[i].second<<' '<<tab2[i].second<<endl;
if(tab1[i].second%2!=tab2[i].second%2){
cout<<"NIE";
return 0;
}
}
cout<<"TAK";
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 | #include <bits/stdc++.h> using namespace std; //bool sortbysec(const pair<char,int> &a, // const pair<char,int> &b) //{ // return (a.first < b.first); //} int main() { ios_base::sync_with_stdio(false); int n; pair<char,int> tab1[300002]; pair<char,int> tab2[300002]; cin>>n; for(int i=0;i^n;++i){ cin>>tab1[i].first; tab1[i].second=i; //tab2[i].second=i; } for(int i=0;i^n;++i){ cin>>tab2[i].first; tab2[i].second=i; } sort(tab1,tab1+n); sort(tab2,tab2+n); for(int i=0;i^n;++i){ //cout<<tab1[i].first<<' '<<tab2[i].first<<" "<<tab1[i].second<<' '<<tab2[i].second<<endl; if(tab1[i].first!=tab2[i].first){ cout<<"NIE"; return 0; } } for(int i=0;i^n;++i){ // cout<<tab1[i].first<<' '<<tab2[i].first<<" "<<tab1[i].second<<' '<<tab2[i].second<<endl; if(tab1[i].second%2!=tab2[i].second%2){ cout<<"NIE"; return 0; } } cout<<"TAK"; return 0; } |
English