#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define REP(i,n) for(int _n=(n), i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define TRACE(x) cerr << "TRACE(" #x ")" << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << endl;
typedef long long LL; typedef unsigned long long ULL;
#define BIGMOD 1000012177LL
char buf[300010];
vector<char> extract(const string &s, int start, int step)
{
vector<char> res;
for (;start < s.size(); start += step)
{
res.emplace_back(s[start]);
}
return res;
}
bool solve(const string &s1, const string &s2)
{
for (int i=0; i <= 1; i++)
{
auto v1 = extract(s1, i, 2);
auto v2 = extract(s2, i, 2);
sort(v1.begin(), v1.end());
sort(v2.begin(), v2.end());
if (v1 != v2)
{
return false;
}
}
return true;
}
int main() {
int n;
scanf("%d", &n);
scanf("%s", buf);
string s1 = buf;
scanf("%s", buf);
string s2 = buf;
bool answer = solve(s1, s2);
printf(answer ? "TAK\n" : "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 42 43 44 45 46 47 48 49 50 51 52 53 54 | #include <bits/stdc++.h> #include <unistd.h> using namespace std; #define REP(i,n) for(int _n=(n), i=0;i<_n;++i) #define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i) #define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i) #define TRACE(x) cerr << "TRACE(" #x ")" << endl; #define DEBUG(x) cerr << #x << " = " << (x) << endl; typedef long long LL; typedef unsigned long long ULL; #define BIGMOD 1000012177LL char buf[300010]; vector<char> extract(const string &s, int start, int step) { vector<char> res; for (;start < s.size(); start += step) { res.emplace_back(s[start]); } return res; } bool solve(const string &s1, const string &s2) { for (int i=0; i <= 1; i++) { auto v1 = extract(s1, i, 2); auto v2 = extract(s2, i, 2); sort(v1.begin(), v1.end()); sort(v2.begin(), v2.end()); if (v1 != v2) { return false; } } return true; } int main() { int n; scanf("%d", &n); scanf("%s", buf); string s1 = buf; scanf("%s", buf); string s2 = buf; bool answer = solve(s1, s2); printf(answer ? "TAK\n" : "NIE\n"); return 0; } |
English