#include <bits/stdc++.h> using namespace std; pair<vector<int>, vector<int>> oddEvenLetters(string s) { vector<int> cnt[2]; for (int i = 0; i < 2; i++) { cnt[i].resize('z'-'a'+1); } for (int i = 0; i < (int)s.size(); i++) { cnt[i % 2][s[i] - 'a']++; } return make_pair(cnt[0], cnt[1]); } int main() { ios_base::sync_with_stdio(false); int n; cin >> n; string s1, s2; cin >> s1 >> s2; if (oddEvenLetters(s1) == oddEvenLetters(s2)) { cout << "TAK\n"; } else { cout << "NIE\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 | #include <bits/stdc++.h> using namespace std; pair<vector<int>, vector<int>> oddEvenLetters(string s) { vector<int> cnt[2]; for (int i = 0; i < 2; i++) { cnt[i].resize('z'-'a'+1); } for (int i = 0; i < (int)s.size(); i++) { cnt[i % 2][s[i] - 'a']++; } return make_pair(cnt[0], cnt[1]); } int main() { ios_base::sync_with_stdio(false); int n; cin >> n; string s1, s2; cin >> s1 >> s2; if (oddEvenLetters(s1) == oddEvenLetters(s2)) { cout << "TAK\n"; } else { cout << "NIE\n"; } } |