#include <bits/stdc++.h> using namespace std; int _count[26][2]; int _count2[26][2]; int main() { int n; char c; cin >> n; for (int i = 0; i < n; i++) { cin >> c; _count[c - 'a'][i % 2]++; } for (int i = 0; i < n; i++) { cin >> c; _count2[c - 'a'][i % 2]++; } for (int i = 0; i < 26; i++) { if (_count[i][0] != _count2[i][0] || _count[i][1] != _count2[i][1]) { 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 | #include <bits/stdc++.h> using namespace std; int _count[26][2]; int _count2[26][2]; int main() { int n; char c; cin >> n; for (int i = 0; i < n; i++) { cin >> c; _count[c - 'a'][i % 2]++; } for (int i = 0; i < n; i++) { cin >> c; _count2[c - 'a'][i % 2]++; } for (int i = 0; i < 26; i++) { if (_count[i][0] != _count2[i][0] || _count[i][1] != _count2[i][1]) { cout << "NIE\n"; return 0; } }cout << "TAK\n"; } |