#include <bits/stdc++.h> using namespace std; #define mk make_pair #define fi first #define sz(x) x.size() #define se second #define pb push_back #define VAR(v) #v << " = " << v << " " #define debug if(0) #define M_PI 3.14159265358979323846 typedef complex<long double> C; typedef long long ll; typedef pair<int, int> ii; typedef vector<ll> Matrix; const int maxn = (int)1e6 + 9; const int INF = (int)1e9 + 7; int mod = (int)1e9 + 7; int n; string s1, s2; int tab[26][2]; int main(int argc, char* argv[]) { ios::sync_with_stdio(false); debug; else cin.tie(NULL), cout.tie(NULL); cin>>n; cin>>s1>>s2; for(int i = 0; i < n; i++) tab[s1[i] - 'a'][i%2]++; for(int i = 0; i < n; i++) tab[s2[i] - 'a'][i%2]--; bool res = true; for(int i = 0; i < 26; i++) for(int j = 0; j < 2; j++) res &= (tab[i][j] == 0); if(res) cout<<"TAK\n"; else cout<<"NIE\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 33 34 35 36 37 38 39 40 41 | #include <bits/stdc++.h> using namespace std; #define mk make_pair #define fi first #define sz(x) x.size() #define se second #define pb push_back #define VAR(v) #v << " = " << v << " " #define debug if(0) #define M_PI 3.14159265358979323846 typedef complex<long double> C; typedef long long ll; typedef pair<int, int> ii; typedef vector<ll> Matrix; const int maxn = (int)1e6 + 9; const int INF = (int)1e9 + 7; int mod = (int)1e9 + 7; int n; string s1, s2; int tab[26][2]; int main(int argc, char* argv[]) { ios::sync_with_stdio(false); debug; else cin.tie(NULL), cout.tie(NULL); cin>>n; cin>>s1>>s2; for(int i = 0; i < n; i++) tab[s1[i] - 'a'][i%2]++; for(int i = 0; i < n; i++) tab[s2[i] - 'a'][i%2]--; bool res = true; for(int i = 0; i < 26; i++) for(int j = 0; j < 2; j++) res &= (tab[i][j] == 0); if(res) cout<<"TAK\n"; else cout<<"NIE\n"; return 0; } |