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
#include <iostream>
#include <string>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);

int n,b=0,x=0;
char c[3]={'a','c','g'};
string s;
cin>>n>>s;

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

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

b=b-(3*n);

while (b>2)
{cout<<"o";
b-=3;
x++;}

if (b) 
{cout<<c[b];
x++;}
n=n-x;

while (n--)
{cout<<"a";}

return 0;
}