#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string a,b; int n; cin>>n; cin>>a; cin>>b; string np1, np2, p1, p2; for(int i=0; i<(n/2)+n%2;i++) { p1+=a[2*i]; np1+=a[2*i+1]; p2+=b[2*i]; np2+=b[2*i+1]; } sort(p1.begin(),p1.end()); sort(np1.begin(),np1.end()); sort(p2.begin(),p2.end()); sort(np2.begin(),np2.end()); if(!p1.compare(p2)&&!np1.compare(np2)) 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 | #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string a,b; int n; cin>>n; cin>>a; cin>>b; string np1, np2, p1, p2; for(int i=0; i<(n/2)+n%2;i++) { p1+=a[2*i]; np1+=a[2*i+1]; p2+=b[2*i]; np2+=b[2*i+1]; } sort(p1.begin(),p1.end()); sort(np1.begin(),np1.end()); sort(p2.begin(),p2.end()); sort(np2.begin(),np2.end()); if(!p1.compare(p2)&&!np1.compare(np2)) cout<<"TAK"; else cout<<"NIE"; return 0; } |