#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; string a, b; cin>>a>>b; vector<array<int, 2>> cnt(26); for(int i = 0; i < 26; i++){ cnt[i][0] = 0; cnt[i][1] = 0; } for(int i = 0; i < n; i++){ cnt[(a[i] - 'a')][i%2]++; cnt[(b[i] - 'a')][i%2]--; } bool result = true; for(int i = 0; i < 26; i++){ if(cnt[i][0] != 0 || cnt[i][1] != 0){ result = false; } } if(result)cout<<"TAK"; else cout<<"NIE"; 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 | #include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; string a, b; cin>>a>>b; vector<array<int, 2>> cnt(26); for(int i = 0; i < 26; i++){ cnt[i][0] = 0; cnt[i][1] = 0; } for(int i = 0; i < n; i++){ cnt[(a[i] - 'a')][i%2]++; cnt[(b[i] - 'a')][i%2]--; } bool result = true; for(int i = 0; i < 26; i++){ if(cnt[i][0] != 0 || cnt[i][1] != 0){ result = false; } } if(result)cout<<"TAK"; else cout<<"NIE"; return 0; } |