#include <iostream> #include <vector> #include <string> int main() { int n; std::cin >> n; std::vector<int> LetterCount1; std::vector<int> LetterCount2; LetterCount1.resize(26 * 2, 0); LetterCount2.resize(26 * 2, 0); for (int i = 0; i < n; i++) { char Letter; std::cin >> Letter; if (i % 2 == 0) { LetterCount1[Letter - 'a']++; } else { LetterCount1[Letter - 'a' + 26]++; } } for (int i = 0; i < n; i++) { char Letter; std::cin >> Letter; if (i % 2 == 0) { LetterCount2[Letter - 'a']++; } else { LetterCount2[Letter - 'a' + 26]++; } } int Diff = 0; for (int i = 0; i < 2 * 26; i++) { if (LetterCount1[i] != LetterCount2[i]) { Diff++; } } if (Diff == 0) { std::cout << "TAK" << std::endl; } else { std::cout << "NIE" << std::endl; } }
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | #include <iostream> #include <vector> #include <string> int main() { int n; std::cin >> n; std::vector<int> LetterCount1; std::vector<int> LetterCount2; LetterCount1.resize(26 * 2, 0); LetterCount2.resize(26 * 2, 0); for (int i = 0; i < n; i++) { char Letter; std::cin >> Letter; if (i % 2 == 0) { LetterCount1[Letter - 'a']++; } else { LetterCount1[Letter - 'a' + 26]++; } } for (int i = 0; i < n; i++) { char Letter; std::cin >> Letter; if (i % 2 == 0) { LetterCount2[Letter - 'a']++; } else { LetterCount2[Letter - 'a' + 26]++; } } int Diff = 0; for (int i = 0; i < 2 * 26; i++) { if (LetterCount1[i] != LetterCount2[i]) { Diff++; } } if (Diff == 0) { std::cout << "TAK" << std::endl; } else { std::cout << "NIE" << std::endl; } } |