#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
int n;
string bajtus, bitus;
int chars[2][300] = {};
cin >> n;
cin >> bajtus >> bitus;
for (int i=0; i<n; i++) {
chars[i%2][bajtus[i]]++;
chars[i%2][bitus[i]]--;
}
if (
*max_element(chars[0] + 'a', chars[0] + 'z' + 1) == 0 && *min_element(chars[0] + 'a', chars[0] + 'z' + 1) == 0 &&
*max_element(chars[1] + 'a', chars[1] + 'z' + 1) == 0 && *min_element(chars[1] + 'a', chars[1] + 'z' + 1) == 0
) {
cout << "TAK";
return 0;
}
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 | #include <iostream> #include <string> #include <algorithm> using namespace std; int main() { int n; string bajtus, bitus; int chars[2][300] = {}; cin >> n; cin >> bajtus >> bitus; for (int i=0; i<n; i++) { chars[i%2][bajtus[i]]++; chars[i%2][bitus[i]]--; } if ( *max_element(chars[0] + 'a', chars[0] + 'z' + 1) == 0 && *min_element(chars[0] + 'a', chars[0] + 'z' + 1) == 0 && *max_element(chars[1] + 'a', chars[1] + 'z' + 1) == 0 && *min_element(chars[1] + 'a', chars[1] + 'z' + 1) == 0 ) { cout << "TAK"; return 0; } cout << "NIE"; return 0; } |
English