#include <iostream>
#define BEG 97
using namespace std;
bool isPos() {
int n;
string str1, str2;
cin >> n;
cin >> str1;
cin >> str2;
int** zab = new int* [2];
zab[0] = new int[26];
zab[1] = new int[26];
for (int i = 0; i < n; i++) {
for (int j = 0; j < 2; j++)
zab[j][i] = 0;
}
for (int i = 0; i < n; i++) {
zab[i % 2][str1[i] - BEG]++;
}
for (int i = 0; i < n; i++) {
zab[i % 2][str2[i] - BEG]--;
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < 2; j++)
if (zab[j][i])
return false;
}
return true;
}
int main()
{
if (isPos()) {
cout << "TAK" << endl;
}
else {
cout << "NIE" << 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 48 | #include <iostream> #define BEG 97 using namespace std; bool isPos() { int n; string str1, str2; cin >> n; cin >> str1; cin >> str2; int** zab = new int* [2]; zab[0] = new int[26]; zab[1] = new int[26]; for (int i = 0; i < n; i++) { for (int j = 0; j < 2; j++) zab[j][i] = 0; } for (int i = 0; i < n; i++) { zab[i % 2][str1[i] - BEG]++; } for (int i = 0; i < n; i++) { zab[i % 2][str2[i] - BEG]--; } for (int i = 0; i < n; i++) { for (int j = 0; j < 2; j++) if (zab[j][i]) return false; } return true; } int main() { if (isPos()) { cout << "TAK" << endl; } else { cout << "NIE" << endl; } return 0; } |
English