#include <algorithm>
#include <iostream>
#include <vector>
void read(int n, std::vector<char> &odd, std::vector<char> &even) {
for (int i = 1; i <= n; ++i) {
if (i % 2 == 0) {
std::cin >> even[i / 2 - 1];
} else {
std::cin >> odd[i / 2];
}
}
}
bool compare(const std::vector<char> &a, const std::vector<char> &b) {
for (size_t i = 0; i < a.size(); ++i) {
if (a[i] != b[i]) {
return false;
}
}
return true;
}
int main() {
int N = 0;
std::cin >> N;
std::vector<char> bitusOdd(N);
std::vector<char> bitusEven(N);
std::vector<char> bajtusOdd(N);
std::vector<char> bajtusEven(N);
read(N, bitusOdd, bitusEven);
read(N, bajtusOdd, bajtusEven);
std::sort(bitusOdd.begin(), bitusOdd.end());
std::sort(bitusEven.begin(), bitusEven.end());
std::sort(bajtusOdd.begin(), bajtusOdd.end());
std::sort(bajtusEven.begin(), bajtusEven.end());
if (compare(bitusOdd, bajtusOdd) && compare(bitusEven, bajtusEven)) {
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 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 | #include <algorithm> #include <iostream> #include <vector> void read(int n, std::vector<char> &odd, std::vector<char> &even) { for (int i = 1; i <= n; ++i) { if (i % 2 == 0) { std::cin >> even[i / 2 - 1]; } else { std::cin >> odd[i / 2]; } } } bool compare(const std::vector<char> &a, const std::vector<char> &b) { for (size_t i = 0; i < a.size(); ++i) { if (a[i] != b[i]) { return false; } } return true; } int main() { int N = 0; std::cin >> N; std::vector<char> bitusOdd(N); std::vector<char> bitusEven(N); std::vector<char> bajtusOdd(N); std::vector<char> bajtusEven(N); read(N, bitusOdd, bitusEven); read(N, bajtusOdd, bajtusEven); std::sort(bitusOdd.begin(), bitusOdd.end()); std::sort(bitusEven.begin(), bitusEven.end()); std::sort(bajtusOdd.begin(), bajtusOdd.end()); std::sort(bajtusEven.begin(), bajtusEven.end()); if (compare(bitusOdd, bajtusOdd) && compare(bitusEven, bajtusEven)) { std::cout << "TAK" << std::endl; } else { std::cout << "NIE" << std::endl; } return 0; } |
English