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
56
57
58
59
60
#include <iostream>
#include <string>
#include <map>

int main() {
	std::map<char, int> even1, even2, odd1, odd2;

	int howManyToys;
	std::string input1, input2;
	std::cin >> howManyToys >> input1 >> input2;

	for (int i = 0; i < howManyToys; i++) {
		if (i % 2 == 0) {
			//input1
			if (odd1.find(input1[i]) == odd1.end()) {
				odd1[input1[i]] = 1;
			}
			else {
				odd1[input1[i]] += 1;
			}

			//input2
			if (odd2.find(input2[i]) == odd2.end()) {
				odd2[input2[i]] = 1;
			}
			else {
				odd2[input2[i]] += 1;
			}
		} else {
			//input1
			if (even1.find(input1[i]) == even1.end()) {
				even1[input1[i]] = 1;
			}
			else {
				even1[input1[i]] += 1;
			}

			//input2
			if (even2.find(input2[i]) == even2.end()) {
				even2[input2[i]] = 1;
			}
			else {
				even2[input2[i]] += 1;
			}
		}
	}

	if (even1.size() != even2.size() || odd1.size() != odd2.size()) {
		std::cout << "NIE";
		return 0;
	}

	if (odd1 == odd2 && even1 == even2) {
		std::cout << "TAK";
		return 0;
	}

	std::cout << "NIE";
	return 0;
}