#include<bits/stdc++.h> #define f first #define s second using namespace std; const int N = ((int)(3e5))+50; int n; char in; pair <char, int> t1[N]; pair <char, int> t2[N]; int main(){ ios_base::sync_with_stdio( 0 ); cin.tie( 0 ); cout.tie( 0 ); cin>>n; for (int i = 0; i < n; i++){ cin>>in; t1[i] = { in , i % 2}; } for (int i = 0; i < n; i++){ cin>>in; t2[i] = { in , i % 2}; } sort(t1, t1+n); sort(t2, t2+n); for (int i = 0; i < n; i++){ if( ( t1[i].f != t2[i].f ) || ( t1[i].s != t2[i].s ) ){ 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 | #include<bits/stdc++.h> #define f first #define s second using namespace std; const int N = ((int)(3e5))+50; int n; char in; pair <char, int> t1[N]; pair <char, int> t2[N]; int main(){ ios_base::sync_with_stdio( 0 ); cin.tie( 0 ); cout.tie( 0 ); cin>>n; for (int i = 0; i < n; i++){ cin>>in; t1[i] = { in , i % 2}; } for (int i = 0; i < n; i++){ cin>>in; t2[i] = { in , i % 2}; } sort(t1, t1+n); sort(t2, t2+n); for (int i = 0; i < n; i++){ if( ( t1[i].f != t2[i].f ) || ( t1[i].s != t2[i].s ) ){ cout<<"NIE"; return 0; } } cout<<"TAK"; return 0; } |