/* * author: pavveu * task: Potyczki Algorytmiczne 2020 Runda 2 - Zabawki [C] */ #include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vll = vector<ll>; #define FOR(iter, val) for(int iter = 0; iter < (val); iter++) #define all(x) begin(x), end(x) void go() { int n; cin >> n; string a, b; cin >> a >> b; const int ASCII_MAX { 1<<8 }; // count letters on odd and even positions int a_parity_cnt[2][ASCII_MAX] = { 0 }; int b_parity_cnt[2][ASCII_MAX] = { 0 }; int odd{}; odd = 0; for ( char x : a ) { a_parity_cnt[odd][(int) x]++; odd ^= 1; } odd = 0; for ( char x : b ) { b_parity_cnt[odd][(int) x]++; odd ^= 1; } bool possible = true; FOR(parity, 2) { FOR(x, ASCII_MAX) { if ( a_parity_cnt[parity][x] != b_parity_cnt[parity][x] ) possible = false; } } cout << (possible? "TAK" : "NIE") << endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); go(); 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 50 51 52 53 54 55 56 57 58 | /* * author: pavveu * task: Potyczki Algorytmiczne 2020 Runda 2 - Zabawki [C] */ #include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vll = vector<ll>; #define FOR(iter, val) for(int iter = 0; iter < (val); iter++) #define all(x) begin(x), end(x) void go() { int n; cin >> n; string a, b; cin >> a >> b; const int ASCII_MAX { 1<<8 }; // count letters on odd and even positions int a_parity_cnt[2][ASCII_MAX] = { 0 }; int b_parity_cnt[2][ASCII_MAX] = { 0 }; int odd{}; odd = 0; for ( char x : a ) { a_parity_cnt[odd][(int) x]++; odd ^= 1; } odd = 0; for ( char x : b ) { b_parity_cnt[odd][(int) x]++; odd ^= 1; } bool possible = true; FOR(parity, 2) { FOR(x, ASCII_MAX) { if ( a_parity_cnt[parity][x] != b_parity_cnt[parity][x] ) possible = false; } } cout << (possible? "TAK" : "NIE") << endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); go(); return 0; } |