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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "stdio.h"
#include <map>

char chain[10 * 10000000] = {0};

using namespace std;
int main ()
{

	map<int,char> mapping;

	mapping.insert(std::pair<int,char>(3, 'a'));
	mapping.insert(std::pair<int,char>(4, 'c'));
	mapping.insert(std::pair<int,char>(5, 'g'));
	mapping.insert(std::pair<int,char>(6, 'o'));

	int n;
	scanf("%d", &n);
	scanf("%s", chain);

	int ones = 0;
	for (int i = 0; i < n; i++)
	{
		for (int k = 0; k < 8; k++)
			ones += chain[8 * i + k] == '1';
		/*
		for (int k = 0; k < 8; k++)
			printf("%c", chain[8 * i + k]);
		printf("\n");
		*/
	}

	// {min, max} = {3 * n, 6 * n}
	if (ones < 3 * n || ones > 6 * n)
	{
		printf("NIE\n");
		return 0;
	}

	int b = ones / n;

	for (int m = 1; m <= n; m++){
		if (b * m + (b + 1) * (n - m) == ones) {
			//printf("%d * %d, %d * %d\n", b, m, b+1, (n-m));
			for (int c = 0; c < m; c++){
				printf("%c", mapping[b]);
			}
			for (int c = 0; c < (n-m); c++){
				printf("%c", mapping[b+1]);
			}
			printf("\n");

			return 0;
		}
	}




	return 0;
}