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
61
62
63
64
65
66
67
68
69
70
#include <iostream>
#include <map>
#include <vector>

using namespace std;

typedef unsigned long UINT;
typedef signed long SINT;

/** Redirect stdin to provide input with Qt Creator */
void reopenInput(int argc, char** argv) {
#ifdef LOCAL
	if (argc > 1) {
		auto inFile = argv[1];
		cerr << "Reopening stdin to: " << inFile << endl;
		auto success = freopen(inFile, "r", stdin);
		if (!success) {
			cerr << "Error when opening file!" << endl;
			cerr << std::strerror(errno) << endl;
		}
	}
#endif
}

static string seq1, seq2;
UINT n;

void processInput()
{
	cin >> n;
	cerr << "N: " << n << endl;
	seq1.reserve(n);
	seq2.reserve(n);

	cin >> seq1 >> seq2;

	cerr << "Sequence 1: " << seq1 << endl;
	cerr << "Sequence 2: " << seq2 << endl;
}

void parseSeq(string &sequence, map<char, UINT> &toycounter, bool odd)
{
	for (UINT i = odd ? 0 : 1; i < sequence.length() ; i += 2) {
		char c = sequence[i];
		toycounter[c] += 1;
	}
}

int main(int argc, char** argv)
{
	reopenInput(argc, argv);
	processInput();

	map<char, UINT> odd1, even1, odd2, even2;

	parseSeq(seq1, odd1, true);
	parseSeq(seq1, even1, false);
	parseSeq(seq2, odd2, true);
	parseSeq(seq2, even2, false);

	bool ok = true;

	for (char c = 'a'; c <= 'z'; c++) {
		if (odd1[c] != odd2[c] || even1[c] != even2[c]) ok = false;
	}

	cout << (ok ? "TAK" : "NIE") << endl;

	return 0;
}