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
55
#include <bits/stdc++.h>
using namespace std;
#define inf 1000000007

bool czy = true;
int n;
string s1, s2;
vector <char> v1p, v1n, v2p, v2n;

int main ()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;
    cin >> s1 >> s2;
    for (int i=0; i<n; i++)
    {
        if (i%2 == 0)
            v1p.push_back(s1[i]);
        else
            v1n.push_back(s1[i]);
    }
    for (int i=0; i<n; i++)
    {
        if (i%2 == 0)
            v2p.push_back(s2[i]);
        else
            v2n.push_back(s2[i]);
    }
    sort(v1p.begin(), v1p.end());
    sort(v1n.begin(), v1n.end());
    sort(v2p.begin(), v2p.end());
    sort(v2n.begin(), v2n.end());

    if (v1p.size() != v2p.size() || v1n.size() != v2n.size())
        czy = false;

    for (int i=0; i<v1p.size(); i++)
    {
        if (v1p[i] != v2p[i])
            czy = false;
    }
    for (int i=0; i<v1n.size(); i++)
    {
        if (v1n[i] != v2n[i])
            czy = false;
    }

    if (czy)
        cout << "TAK\n";
    else
        cout << "NIE\n";
    return 0;
}