#include <iostream> #include <vector> #include <string> int main() { int n; std::cin >> n; std::string a, b; std::cin >> a >> b; std::vector<std::vector<int>> v1(26, std::vector<int>(2)); std::vector<std::vector<int>> v2(26, std::vector<int>(2)); for (int i = 0; i < n; ++i) { ++v1[a[i] - 'a'][i % 2]; ++v2[b[i] - 'a'][i % 2]; } if (v1 == v2) std::cout << "TAK" << std::endl; else std::cout << "NIE" << 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 | #include <iostream> #include <vector> #include <string> int main() { int n; std::cin >> n; std::string a, b; std::cin >> a >> b; std::vector<std::vector<int>> v1(26, std::vector<int>(2)); std::vector<std::vector<int>> v2(26, std::vector<int>(2)); for (int i = 0; i < n; ++i) { ++v1[a[i] - 'a'][i % 2]; ++v2[b[i] - 'a'][i % 2]; } if (v1 == v2) std::cout << "TAK" << std::endl; else std::cout << "NIE" << std::endl; return 0; } |