#include <bits/stdc++.h> using namespace std; using ll = long long; using llu = unsigned long long; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; string a, b; cin >> a >> b; vector<int> cnt_a1(26); vector<int> cnt_a0(26); vector<int> cnt_b1(26); vector<int> cnt_b0(26); for (int i = 0; i < n; i += 2) { cnt_a0[a[i]-'a']++; cnt_b0[b[i]-'a']++; } for (int i = 1; i < n; i += 2) { cnt_a1[a[i]-'a']++; cnt_b1[b[i]-'a']++; } bool good = true; for (int i = 0; i < 26; i++) { if (cnt_a1[i] != cnt_b1[i] || cnt_a0[i] != cnt_b0[i]) good = false; } cout << (const char*[]){"NIE\n", "TAK\n"}[good]; 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 | #include <bits/stdc++.h> using namespace std; using ll = long long; using llu = unsigned long long; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; string a, b; cin >> a >> b; vector<int> cnt_a1(26); vector<int> cnt_a0(26); vector<int> cnt_b1(26); vector<int> cnt_b0(26); for (int i = 0; i < n; i += 2) { cnt_a0[a[i]-'a']++; cnt_b0[b[i]-'a']++; } for (int i = 1; i < n; i += 2) { cnt_a1[a[i]-'a']++; cnt_b1[b[i]-'a']++; } bool good = true; for (int i = 0; i < 26; i++) { if (cnt_a1[i] != cnt_b1[i] || cnt_a0[i] != cnt_b0[i]) good = false; } cout << (const char*[]){"NIE\n", "TAK\n"}[good]; return 0; } |