#include <bits/stdc++.h> using namespace std; #define debug if(0) #define pb push_back #define mp make_pair #define ff first #define ss second #define MAXN 300005 int n; char s1[MAXN], s2[MAXN]; int ile[32][2]; int main() { scanf ("%d", &n); scanf ("%s", s1 + 1); scanf ("%s", s2 + 1); for (int i = 1; i <= n; ++i) { ++ile[s1[i] - 'a'][i&1]; } for (int i = 1; i <= n; ++i) { --ile[s2[i] - 'a'][i&1]; if (ile[s2[i] - 'a'][i&1] < 0) { puts ("NIE"); return 0; } } puts ("TAK"); 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 | #include <bits/stdc++.h> using namespace std; #define debug if(0) #define pb push_back #define mp make_pair #define ff first #define ss second #define MAXN 300005 int n; char s1[MAXN], s2[MAXN]; int ile[32][2]; int main() { scanf ("%d", &n); scanf ("%s", s1 + 1); scanf ("%s", s2 + 1); for (int i = 1; i <= n; ++i) { ++ile[s1[i] - 'a'][i&1]; } for (int i = 1; i <= n; ++i) { --ile[s2[i] - 'a'][i&1]; if (ile[s2[i] - 'a'][i&1] < 0) { puts ("NIE"); return 0; } } puts ("TAK"); return 0; } |