#include <iostream> int count[2][2][26], n; std::string s; bool Check() { for(int i = 0; i < 2; i++) for(int j = 0; j < 26; j++) if(count[0][i][j] != count[1][i][j]) return false; return true; } int main() { std::cin >> n; for(int i = 0; i < 2; i++) { std::cin >> s; for(int j = 0; j < n; j++) count[i][j % 2][s[j] - 'a']++; } std::cout << (Check() ? "TAK" : "NIE") << '\n'; return 0; } /* 7 abcdefg edgbcfa 5 abcde fghhh */
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 | #include <iostream> int count[2][2][26], n; std::string s; bool Check() { for(int i = 0; i < 2; i++) for(int j = 0; j < 26; j++) if(count[0][i][j] != count[1][i][j]) return false; return true; } int main() { std::cin >> n; for(int i = 0; i < 2; i++) { std::cin >> s; for(int j = 0; j < n; j++) count[i][j % 2][s[j] - 'a']++; } std::cout << (Check() ? "TAK" : "NIE") << '\n'; return 0; } /* 7 abcdefg edgbcfa 5 abcde fghhh */ |