#include <iostream> using namespace std; const int SIZE = 1e6 + 6; int parz[SIZE]; int nieparz[SIZE]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; string BIT; string BAJT; cin >> BIT >> BAJT; for (int i = 1; i <= n; ++i) { if (i % 2 == 0) { parz[(int)(BIT[i - 1])]++; } else { nieparz[(int)(BIT[i - 1])]++; } } for (int i = 1; i <= n; ++i) { if (i % 2 == 0) { parz[(int)(BAJT[i - 1])]--; if (parz[(int)(BAJT[i - 1])] < 0) { cout << "NIE"; return 0; } } else { nieparz[(int)(BAJT[i - 1])]--; if (nieparz[(int)(BAJT[i - 1])] < 0) { cout << "NIE"; return 0; } } } cout << "TAK"; }
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 | #include <iostream> using namespace std; const int SIZE = 1e6 + 6; int parz[SIZE]; int nieparz[SIZE]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; string BIT; string BAJT; cin >> BIT >> BAJT; for (int i = 1; i <= n; ++i) { if (i % 2 == 0) { parz[(int)(BIT[i - 1])]++; } else { nieparz[(int)(BIT[i - 1])]++; } } for (int i = 1; i <= n; ++i) { if (i % 2 == 0) { parz[(int)(BAJT[i - 1])]--; if (parz[(int)(BAJT[i - 1])] < 0) { cout << "NIE"; return 0; } } else { nieparz[(int)(BAJT[i - 1])]--; if (nieparz[(int)(BAJT[i - 1])] < 0) { cout << "NIE"; return 0; } } } cout << "TAK"; } |