#include <iostream> int main() { int32_t n; std::cin >> n; std::string bitus, bajtus; std::cin >> bitus >> bajtus; int32_t bitusEven[26] = {}; int32_t bitusOdd[26] = {}; int32_t bajtusEven[26] = {}; int32_t bajtusOdd[26] = {}; for (int32_t i = 0; i < n; ++i) { (i % 2 == 0 ? bitusEven : bitusOdd)[bitus[i] - 'a'] += 1; (i % 2 == 0 ? bajtusEven : bajtusOdd)[bajtus[i] - 'a'] += 1; } bool ok = true; for (int32_t i = 0; i < 26; ++i) { ok &= bitusEven[i] == bajtusEven[i]; ok &= bitusOdd[i] == bajtusOdd[i]; } std::cout << (ok ? "TAK" : "NIE") << "\n"; }
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 | #include <iostream> int main() { int32_t n; std::cin >> n; std::string bitus, bajtus; std::cin >> bitus >> bajtus; int32_t bitusEven[26] = {}; int32_t bitusOdd[26] = {}; int32_t bajtusEven[26] = {}; int32_t bajtusOdd[26] = {}; for (int32_t i = 0; i < n; ++i) { (i % 2 == 0 ? bitusEven : bitusOdd)[bitus[i] - 'a'] += 1; (i % 2 == 0 ? bajtusEven : bajtusOdd)[bajtus[i] - 'a'] += 1; } bool ok = true; for (int32_t i = 0; i < 26; ++i) { ok &= bitusEven[i] == bajtusEven[i]; ok &= bitusOdd[i] == bajtusOdd[i]; } std::cout << (ok ? "TAK" : "NIE") << "\n"; } |