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
#include <stdio.h>
using namespace std;

#define MAX_TYPES 26 * 2
#define CHAR_IDX 97

int main(int argc, char const *argv[]) {
  int i, toysNum, toysATypes[MAX_TYPES], toysBTypes[MAX_TYPES];
  char letter;

  for (i = 0; i < MAX_TYPES; ++i) {
    toysATypes[i] = 0;
    toysBTypes[i] = 0;
  }

  if (!scanf("%d\n", &toysNum)) return 1;

  for (int i = 0; i < toysNum; ++i) {
    if (!scanf("%c", &letter)) return 1;
    ++toysATypes[(i % 2) * MAX_TYPES / 2 + letter - CHAR_IDX];
  }

  if (!scanf("%c\n", &letter)) return 1;

  for (int i = 0; i < toysNum; ++i) {
    if (!scanf("%c", &letter)) return 1;
    ++toysBTypes[(i % 2) * MAX_TYPES / 2 + letter - CHAR_IDX];
  }

  for (i = 0; i < MAX_TYPES; ++i) {
    if (toysATypes[i] != toysBTypes[i]) {
      printf("NIE");

      return 0;
    }
  }
  printf("TAK");

  return 0;
}