#include <iostream> #include <cstdio> #include <map> #include <cmath> #include <cstring> #include <vector> #include <set> #include <algorithm> using namespace std; string a, b; int n; int xnp[300]; int ynp[300]; int xp[300]; int yp[300]; int main(){ cin>>n; cin>>a; cin>>b; for(int i=0; i<300; i++){ xp[i]=yp[i]=ynp[i]=xnp[i]=0; } for(int i=0; i<=n; i++){ if(i&1){ xnp[int(a[i])]++; ynp[int(b[i])]++; } else { xp[int(a[i])]++; yp[int(b[i])]++; } } for(int i='a'; i<='z'; i++){ if(xnp[i]!=ynp[i] || xp[i]!=yp[i]){ cout<<"NIE"<<endl; return 0; } } cout<<"TAK"<<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 | #include <iostream> #include <cstdio> #include <map> #include <cmath> #include <cstring> #include <vector> #include <set> #include <algorithm> using namespace std; string a, b; int n; int xnp[300]; int ynp[300]; int xp[300]; int yp[300]; int main(){ cin>>n; cin>>a; cin>>b; for(int i=0; i<300; i++){ xp[i]=yp[i]=ynp[i]=xnp[i]=0; } for(int i=0; i<=n; i++){ if(i&1){ xnp[int(a[i])]++; ynp[int(b[i])]++; } else { xp[int(a[i])]++; yp[int(b[i])]++; } } for(int i='a'; i<='z'; i++){ if(xnp[i]!=ynp[i] || xp[i]!=yp[i]){ cout<<"NIE"<<endl; return 0; } } cout<<"TAK"<<endl; return 0; } |