#include<bits/stdc++.h> using namespace std; char p; vector<char> an, ap, bn, bp; int n, i; int main(){ scanf("%d", &n); for(i = 0; i < n; i++){ scanf(" %c", &p); if(i&1) an.push_back(p); else ap.push_back(p); } for(i = 0; i < n; i++){ scanf(" %c", &p); if(i&1) bn.push_back(p); else bp.push_back(p); } sort(an.begin(), an.end()); sort(ap.begin(), ap.end()); sort(bn.begin(), bn.end()); sort(bp.begin(), bp.end()); if(an == bn && ap == bp) printf("TAK"); else printf("NIE"); }
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 | #include<bits/stdc++.h> using namespace std; char p; vector<char> an, ap, bn, bp; int n, i; int main(){ scanf("%d", &n); for(i = 0; i < n; i++){ scanf(" %c", &p); if(i&1) an.push_back(p); else ap.push_back(p); } for(i = 0; i < n; i++){ scanf(" %c", &p); if(i&1) bn.push_back(p); else bp.push_back(p); } sort(an.begin(), an.end()); sort(ap.begin(), ap.end()); sort(bn.begin(), bn.end()); sort(bp.begin(), bp.end()); if(an == bn && ap == bp) printf("TAK"); else printf("NIE"); } |