#include <bits/stdc++.h> using namespace std; typedef long long ll; #ifdef LOCAL #define debug(...) __VA_ARGS__ #else #define debug(...) {} #endif int cnt_a[27][2]; int cnt_b[27][2]; int main(){ ios_base::sync_with_stdio(0); cin.tie(); cout.tie(); int i; int n; cin>>n; string a,b; cin>>a>>b; for (i = 0; i < n; i++) cnt_a[int(a[i])-int('a')][i%2]++; for (i = 0; i < n ; i++) cnt_b[int(b[i])-int('a')][i%2]++; for (i = 0; i < 27; i++){ for (int j = 0; j < 2; j++){ if (cnt_a[i][j] != cnt_b[i][j]){ cout<<"NIE\n"; return 0; } } } cout<<"TAK\n"; 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 27 28 29 30 31 32 | #include <bits/stdc++.h> using namespace std; typedef long long ll; #ifdef LOCAL #define debug(...) __VA_ARGS__ #else #define debug(...) {} #endif int cnt_a[27][2]; int cnt_b[27][2]; int main(){ ios_base::sync_with_stdio(0); cin.tie(); cout.tie(); int i; int n; cin>>n; string a,b; cin>>a>>b; for (i = 0; i < n; i++) cnt_a[int(a[i])-int('a')][i%2]++; for (i = 0; i < n ; i++) cnt_b[int(b[i])-int('a')][i%2]++; for (i = 0; i < 27; i++){ for (int j = 0; j < 2; j++){ if (cnt_a[i][j] != cnt_b[i][j]){ cout<<"NIE\n"; return 0; } } } cout<<"TAK\n"; return 0; } |