#include <iostream>
#include <string>
#ifdef HOME_
#define PRINT(x) cerr<<x
#else
#define PRINT(x)
#endif
#define REP(x,n) for(int x=0;x<(n);++x)
#define FROMCHAR(x) (x-'a')
using namespace std;
const int SIZE = 'z'-'a'+1;
int parz[SIZE], nparz[SIZE];
int n;
string s;
bool solve() {
cin>>n>>s;
REP(x,n)
if (x&1)
++nparz[FROMCHAR(s[x])];
else
++parz[FROMCHAR(s[x])];
cin>>s;
REP(x,n)
if (x&1)
--nparz[FROMCHAR(s[x])];
else
--parz[FROMCHAR(s[x])];
REP(x,SIZE)
if (parz[x] || nparz[x])
return false;
return true;
}
int main() {
ios_base::sync_with_stdio(0);
if (solve())
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | #include <iostream> #include <string> #ifdef HOME_ #define PRINT(x) cerr<<x #else #define PRINT(x) #endif #define REP(x,n) for(int x=0;x<(n);++x) #define FROMCHAR(x) (x-'a') using namespace std; const int SIZE = 'z'-'a'+1; int parz[SIZE], nparz[SIZE]; int n; string s; bool solve() { cin>>n>>s; REP(x,n) if (x&1) ++nparz[FROMCHAR(s[x])]; else ++parz[FROMCHAR(s[x])]; cin>>s; REP(x,n) if (x&1) --nparz[FROMCHAR(s[x])]; else --parz[FROMCHAR(s[x])]; REP(x,SIZE) if (parz[x] || nparz[x]) return false; return true; } int main() { ios_base::sync_with_stdio(0); if (solve()) cout << "TAK"; else cout << "NIE"; return 0; } |
English