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

int n;
std::string s;
std::string res = "";

int map[4] = {'a','c','g','o'}; 

int main()
{
	std::cin >> n;
	std::cin >> s;
	int ones = 0;
	for( int i = 0; i < s.size(); i++ )	if( s[i] == '1' ) ones++;
	int avg = ones/n;
	int big = ones - n*avg;
	if( (big > 0 && avg == 6) || avg > 6 || avg < 3 )
	{
		std::cout << "NIE\n";
		return 0;
	}
	for( int i = 0; i < big; i++ )	res += map[avg - 2];
	for( int i = big; i < n; i++ )  res += map[avg - 3];
	std::cout << res << '\n';
	return 0;
}