#include <bits/stdc++.h> using namespace std; int tak1[26]; int nie1[26]; int tak2[26]; int nie2[26]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; string a, b; cin >> a >> b; for(int i=0;i<n;i+=2) { tak1[a[i]-'a']++; tak2[b[i]-'a']++; } for(int i=1;i<n;i+=2) { nie1[a[i]-'a']++; nie2[b[i]-'a']++; } for(int i=0;i<26;i++) { if(tak1[i] != tak2[i] or nie1[i] != nie2[i]) { 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 27 28 29 30 31 32 | #include <bits/stdc++.h> using namespace std; int tak1[26]; int nie1[26]; int tak2[26]; int nie2[26]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; string a, b; cin >> a >> b; for(int i=0;i<n;i+=2) { tak1[a[i]-'a']++; tak2[b[i]-'a']++; } for(int i=1;i<n;i+=2) { nie1[a[i]-'a']++; nie2[b[i]-'a']++; } for(int i=0;i<26;i++) { if(tak1[i] != tak2[i] or nie1[i] != nie2[i]) { cout << "NIE\n"; return 0; } } cout << "TAK\n"; } |