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
#include <cstdio>
#include <map>
#include <set>
#include <utility>

int n;
int remaining_ones_count = 0;

int main() {
  scanf("%d\n", &n);
  for (int i=0; i < n * 8; i++) {
    char c;
    scanf("%c", &c);
    if (c == '1') {
      remaining_ones_count ++;
    }
  }
  //printf("%d\n", remaining_ones_count);
  char* result = new char[n];
  int index = 0;
  if (3 * n <= remaining_ones_count && remaining_ones_count <= 6 * n) {
    for (int i=0; i<n; i++) {
      int ones_count = 6;
      while (3*(n-i-1) > remaining_ones_count - ones_count) {
        ones_count --;
      }

      remaining_ones_count -= ones_count;
      if (ones_count == 3) {
        printf("a");
      } else if (ones_count == 4) {
        printf("c");
      } else if (ones_count == 5) {
        printf("g");
      } else {
        printf("o");
      }
    }
  } else {
    printf("NIE");
  }

  return 0;
}