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

using namespace std;

const int maxBit = 4000000;
char tab[maxBit];
int n, ile[2];
int main()
{
	cin >> n;
	for (int i = 0; i < n * 8; i++)
	{
		cin >> tab[i];
		ile[tab[i] - '0']++;
	}

	if (!(ile[0] >= 2 * n && ile[1] >= 3 * n && ile[0] <= 5 * n && ile[1] <= 6 * n))
	{
		cout << "NIE";
		return 0;
	}

	ile[0] -= n;
	ile[1] -= 2 * n;

	int dziel = ile[1] / n, mod = ile[1] % n;
	for (int i = 0; i < n; i++)
	{
		int d = dziel;
		if (mod != 0)
		{
			d++;
			mod--;
		}
		switch (d)
		{
			case 1:
				cout << 'a';
				break;
			case 2:
				cout << 'c';
				break;
			case 3:
				cout << 'g';
				break;
			case 4:
				cout << 'o';
				break;
		}
	}
	return 0;
}