#include <iostream> #include <vector> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; cin >> n; string bitus_toys, bajtus_toys; cin >> bitus_toys >> bajtus_toys; vector<pair<int, int>> bitus_idx(26); vector<pair<int, int>> bajtus_idx(26); //ilość liter na nieparzystych i parzystych pozycjach for (int i = 0; i < n; i++) { if (i % 2 == 0) { bitus_idx[int(bitus_toys[i]) - 97].second++; bajtus_idx[int(bajtus_toys[i]) - 97].second++; } else { bitus_idx[int(bitus_toys[i]) - 97].first++; bajtus_idx[int(bajtus_toys[i]) - 97].first++; } } for (int i = 0; i < 26; i++) { if (bitus_idx[i].first != bajtus_idx[i].first || bitus_idx[i].second != bajtus_idx[i].second) { cout << "NIE"; return 0; } } cout << "TAK"; 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 | #include <iostream> #include <vector> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; cin >> n; string bitus_toys, bajtus_toys; cin >> bitus_toys >> bajtus_toys; vector<pair<int, int>> bitus_idx(26); vector<pair<int, int>> bajtus_idx(26); //ilość liter na nieparzystych i parzystych pozycjach for (int i = 0; i < n; i++) { if (i % 2 == 0) { bitus_idx[int(bitus_toys[i]) - 97].second++; bajtus_idx[int(bajtus_toys[i]) - 97].second++; } else { bitus_idx[int(bitus_toys[i]) - 97].first++; bajtus_idx[int(bajtus_toys[i]) - 97].first++; } } for (int i = 0; i < 26; i++) { if (bitus_idx[i].first != bajtus_idx[i].first || bitus_idx[i].second != bajtus_idx[i].second) { cout << "NIE"; return 0; } } cout << "TAK"; return 0; } |