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
#include <iostream>
#include <string>

using namespace std;

void count_letters(std::string s, int parr[], int narr[], int n)
{
    for(int i = 0;i < n;i+=2)
        ++parr[s[i]-97];
    for(int i = 1;i < n;i+=2)
        ++narr[s[i]-97];
}

int main()
{
    int p1[26] = {};
    int n1[26] = {};

    int p2[26] = {};
    int n2[26] = {};

    int n;
    std::string s1,s2;

    std::cin >> n >> s1 >> s2;
    count_letters(s1,p1,n1,n);
    count_letters(s2,p2,n2,n);

    for(int i = 0;i < 26;++i)
        if(p1[i] != p2[i] || n1[i] != n2[i])
        {
            cout << "NIE";
            return 0;
        }
    cout << "TAK";
    return 0;
}