#include <bits/stdc++.h> #define FOR(i, a, b) for(int i = a; i<b; ++i) #define FR(a, b) for(int i = a; i>=b;--i) #define _upgrade cin.tie(0); ios_base::sync_with_stdio(0) #define pb push_back #define mp make_pair #define INF 1e13 using namespace std; typedef long long ll; typedef double db; typedef unsigned long long ull; typedef pair<int, int> iPair; const int MAX = 1e6 + 2; const int M = 1e9 +7; int n, cnt[26][2], cnt1[26][2]; bool solve() { FOR(i, 0, 26) if(cnt[i][0] != cnt1[i][0] || cnt[i][1] != cnt1[i][1]) return 0; return 1; } int main() { _upgrade; string s, s1; cin>>n>>s>>s1; FOR(i, 0, n) { cnt[s[i]-'a'][i&1]++; cnt1[s1[i]-'a'][i&1]++; } if(solve()) 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 33 34 35 36 37 38 39 40 41 42 | #include <bits/stdc++.h> #define FOR(i, a, b) for(int i = a; i<b; ++i) #define FR(a, b) for(int i = a; i>=b;--i) #define _upgrade cin.tie(0); ios_base::sync_with_stdio(0) #define pb push_back #define mp make_pair #define INF 1e13 using namespace std; typedef long long ll; typedef double db; typedef unsigned long long ull; typedef pair<int, int> iPair; const int MAX = 1e6 + 2; const int M = 1e9 +7; int n, cnt[26][2], cnt1[26][2]; bool solve() { FOR(i, 0, 26) if(cnt[i][0] != cnt1[i][0] || cnt[i][1] != cnt1[i][1]) return 0; return 1; } int main() { _upgrade; string s, s1; cin>>n>>s>>s1; FOR(i, 0, n) { cnt[s[i]-'a'][i&1]++; cnt1[s1[i]-'a'][i&1]++; } if(solve()) cout<<"TAK\n"; else cout<<"NIE\n"; } |