#include <iostream> using namespace std; int main(int argc, char** argv) { int n; cin >> n; int toys1[2 * 26] = {0}; int toys2[2 * 26] = {0}; string word; cin >> word; for (int i = 0; i<n; i++) { toys1[(word[i] - 'a') + (i % 2 == 0 ? 0 : 26)]++; } string word2; cin >> word2; for (int i = 0; i<n; i++) { toys2[(word2[i] - 'a') + (i % 2 == 0 ? 0 : 26)]++; } bool canComplete = true; for (int i = 0; i < 2 * 26; i++) { if (toys1[i] != toys2[i]){ canComplete = false; break; } } if (canComplete) { 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 | #include <iostream> using namespace std; int main(int argc, char** argv) { int n; cin >> n; int toys1[2 * 26] = {0}; int toys2[2 * 26] = {0}; string word; cin >> word; for (int i = 0; i<n; i++) { toys1[(word[i] - 'a') + (i % 2 == 0 ? 0 : 26)]++; } string word2; cin >> word2; for (int i = 0; i<n; i++) { toys2[(word2[i] - 'a') + (i % 2 == 0 ? 0 : 26)]++; } bool canComplete = true; for (int i = 0; i < 2 * 26; i++) { if (toys1[i] != toys2[i]){ canComplete = false; break; } } if (canComplete) { cout << "TAK" << endl; } else { cout << "NIE" << endl; } return 0; } |