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
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main() {
  int n, ones = 0;
  char outputWithNOnes[9] = {'\0', '\0', '\0', 'a', 'c', 'g', 'o', '\0', '\0'};
  string input;
  cin >> n >> input;
  for (int i = 0; i < n * 8; i++)
    if (input[i] == '1')
      ones++;

  if (ones < n * 3 || ones > n * 6)
    cout << "NIE" << endl;
  else {
    int lowCount, highCount;
    highCount = ones % n;
    lowCount = n - highCount;

    for (int i = 0; i < lowCount; i++)
      cout << outputWithNOnes[ones / n];
    for (int i = 0; i < highCount; i++)
      cout << outputWithNOnes[ones / n + 1];

    cout << endl;
  }
  return 0;
}