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

using namespace std;

const char letters[] = { 'a', 'c', 'g', 'o', '_' };

int main()
{
	int n;

	cin >> n;

	string bits;

	cin >> bits;

	int cnt = 0;

	for (int i = 0; i < 8 * n; ++i)
	{
		cnt += bits[i] - '0';
	}

	string res = "NIE";

	if (cnt >= 3 * n && cnt <= 6 * n)
	{
		cnt -= 3 * n;

		int x = cnt / n;
		int y = cnt % n;

		string s1(n - y, letters[x]);
		string s2(y, letters[x + 1]);

		res = s1 + s2;
	}

	cout << res << endl;

	return 0;
}