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 <algorithm>
#include <cstdio>
#include <vector>
#include <set>

using namespace std;

long a[121];

int main()
{
	long n, l=0;
	char c;
	scanf("%ld\n", &n);
	for (long i = 0; i < n*8; ++i)
	{
		scanf("%c", &c);
		l += c - '0';
	}

  if (l < n*3 || l > n*6)
	{
		printf("%s", "NIE");
    return 0;
	}

  char res[] = "012acgo";
  for (long i=3; i <= 6; ++i)
		while (n > 0 && l-i <= (n-1)*6)
		{
			printf("%c", res[i]);
			l -= i;
			--n;
		}

	return 0;
}