#include <iostream>
using namespace std;
int main()
{
int n;
string a,b;
const int d = n;
int * tab = new int [26];
int * tab1 = new int [26];
for(int i=0; i<26; ++i){
tab[i] = 0;
tab1[i] = 0;
}
cin >> n;
cin >> a >> b;
for(int i=0; i<n; ++i){
tab[int(a[i]-97)]++;
}
for(int i=0; i<n; ++i){
tab1[int(b[i]-97)]++;
}
bool is_good = true;
for(int i=0; i<26; ++i){
if(tab[i]!=tab1[i]){
is_good = false;
}
}
if(!is_good){
cout << "NIE";
}
else{
bool check = true;
int t [26][n];
int t1 [26][n];
for(int i=0; i<26; ++i){
for(int j=0; j<n; ++j){
t[i][j] = -1;
t1[i][j] = -1;
}
}
int temp = 0;
int tablica [26];
int tablica2 [26];
for(int i=0; i<26; ++i){
tablica[i]=0;
tablica2[i]=0;
}
for(int i=0; i<n; ++i){
t[int(a[i]-97)][tablica[int(a[i]-97)]] = i;
t1[int(b[i]-97)][tablica2[int(b[i]-97)]] = i;
temp++;
tablica[int(a[i]-97)]++;
tablica2[int(b[i]-97)]++;
}
for(int i=0; i<26; ++i){
for(int j=0; j<n;++j){
if(t[i][j] != -1 && t1[i][j] != -1){
if((t[i][j]+t1[i][j])%2!=0){
check = false;
break;
}
}
}
}
if(check){
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | #include <iostream> using namespace std; int main() { int n; string a,b; const int d = n; int * tab = new int [26]; int * tab1 = new int [26]; for(int i=0; i<26; ++i){ tab[i] = 0; tab1[i] = 0; } cin >> n; cin >> a >> b; for(int i=0; i<n; ++i){ tab[int(a[i]-97)]++; } for(int i=0; i<n; ++i){ tab1[int(b[i]-97)]++; } bool is_good = true; for(int i=0; i<26; ++i){ if(tab[i]!=tab1[i]){ is_good = false; } } if(!is_good){ cout << "NIE"; } else{ bool check = true; int t [26][n]; int t1 [26][n]; for(int i=0; i<26; ++i){ for(int j=0; j<n; ++j){ t[i][j] = -1; t1[i][j] = -1; } } int temp = 0; int tablica [26]; int tablica2 [26]; for(int i=0; i<26; ++i){ tablica[i]=0; tablica2[i]=0; } for(int i=0; i<n; ++i){ t[int(a[i]-97)][tablica[int(a[i]-97)]] = i; t1[int(b[i]-97)][tablica2[int(b[i]-97)]] = i; temp++; tablica[int(a[i]-97)]++; tablica2[int(b[i]-97)]++; } for(int i=0; i<26; ++i){ for(int j=0; j<n;++j){ if(t[i][j] != -1 && t1[i][j] != -1){ if((t[i][j]+t1[i][j])%2!=0){ check = false; break; } } } } if(check){ cout << "TAK"; }else{ cout << "NIE"; } } return 0; } |
English