#include <iostream> #include <string> void countLetters(std::string &text, int letters[][26]) { int base = (int)'a'; for (std::string::size_type i = 0; i < text.size(); i++) { letters[i%2][text[i]-base]+=1; } } int main() { int n; std::cin >> n; std::string textA; std::string textB; std::cin >> textA; std::cin >> textB; int textALetters[2][26] = {{0}}; int textBLetters[2][26] = {{0}}; countLetters(textA, textALetters); countLetters(textB, textBLetters); for(int i=0; i <26; ++i){ if((textALetters[0][i] != textBLetters[0][i]) || (textALetters[1][i] != textBLetters[1][i])) { std::cout << "NIE" << std::endl; return 0; } } std::cout << "TAK" << std::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 | #include <iostream> #include <string> void countLetters(std::string &text, int letters[][26]) { int base = (int)'a'; for (std::string::size_type i = 0; i < text.size(); i++) { letters[i%2][text[i]-base]+=1; } } int main() { int n; std::cin >> n; std::string textA; std::string textB; std::cin >> textA; std::cin >> textB; int textALetters[2][26] = {{0}}; int textBLetters[2][26] = {{0}}; countLetters(textA, textALetters); countLetters(textB, textBLetters); for(int i=0; i <26; ++i){ if((textALetters[0][i] != textBLetters[0][i]) || (textALetters[1][i] != textBLetters[1][i])) { std::cout << "NIE" << std::endl; return 0; } } std::cout << "TAK" << std::endl; return 0; } |