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 <cstdio>

int N;
int J;

#define MAXN 200000
char data[8 * MAXN];

int main() {
  scanf("%d\n", &N);
  scanf("%s", data);
  J = 0;
  for (int i = 0; i < 8 * N; ++i) if (data[i] == '1') J += 1; 
  if ((J < 3 * N) || (J > 6 * N)) {
    printf("NIE\n");
    return 0;
  }
  if (J % 3 == 1) {
    printf("c");
    J -= 4;
    N -= 1;
  }
  if (J % 3 == 2) {
    printf("g");
    J -= 5;
    N -= 1;
  }
  while (J > 3 * N) {
    printf("o");
    J -= 6;
    N -= 1;
  }
  while (N > 0) {
    printf("a");
    J -= 3;
    N -= 1;
  }
  printf("\n");
  return 0;
}