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

using namespace std;

int n; 
string s;
string ans = "000acgw";
long long ile; 

int main() 
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> s;

	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == '1')	ile++; 
	}

	if (ile < n * 3 || ile > n * 6)
	{
		cout << "NIE\n"; 
		return 0; 
	}

	int licz = ile / n; 
	if (licz * n == ile)
	{
		for (int i = 0; i < n; i++)
			cout << ans[licz];
	}

	else
	{
		for (int i = 0; i < n - (ile - n * licz); i++)
			cout << ans[licz]; 
		for (int i = 0; i < ile - n * licz; i++)
			cout << ans[licz + 1];
	}
	
	//+5
	//3*4 + 5*5 = 12 + 25

	//37 8
	//4*8 = 32 +5
	// -1 0 +1 +2
	
	//3*a + 4*b + 5*c + 6*d = ile
	//a+b+c+d = n
	return 0;
}