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
#include <iostream>
using namespace std;

int main()
{
  ios_base::sync_with_stdio(0);

  char tab[7];
  tab[3] = 'a';
  tab[4] = 'c';
  tab[5] = 'g';
  tab[6] = 'o';

  int n;
  char c;
  int ones = 0;
  int print_nr;

  cin >> n;
  for (int i=0; i<8*n; i++) {
    cin >> c;
    if (c == '1')
      ones++;
  }

  if ((ones > n*6) || (ones < n*3))
    cout << "NIE";
  else
    while (n > 0) {
      print_nr = ones / n;
      cout << tab[print_nr];
      ones -= print_nr;
      n--;
    }   

  return 0;
}