#include <iostream> using namespace std; constexpr int S = 'z' - 'a' + 1; int_fast32_t n; char c; int_fast32_t tab1e[S], tab2e[S], tab1o[S], tab2o[S]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n; for (int i = 0; i < n; i++) { cin >> c; if (i&1) tab1o[c - 'a']++; else tab1e[c - 'a']++; } for (int i = 0; i < n; i++) { cin >> c; if (i&1) tab2o[c - 'a']++; else tab2e[c - 'a']++; } for (int i = 0; i < S; i++) { if (tab1e[i] != tab2e[i] || tab1o[i] != tab2o[i]) { cout << "NIE\n"; return 0; } } cout << "TAK\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 27 28 29 30 31 32 33 34 35 36 | #include <iostream> using namespace std; constexpr int S = 'z' - 'a' + 1; int_fast32_t n; char c; int_fast32_t tab1e[S], tab2e[S], tab1o[S], tab2o[S]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n; for (int i = 0; i < n; i++) { cin >> c; if (i&1) tab1o[c - 'a']++; else tab1e[c - 'a']++; } for (int i = 0; i < n; i++) { cin >> c; if (i&1) tab2o[c - 'a']++; else tab2e[c - 'a']++; } for (int i = 0; i < S; i++) { if (tab1e[i] != tab2e[i] || tab1o[i] != tab2o[i]) { cout << "NIE\n"; return 0; } } cout << "TAK\n"; } |