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
#include<iostream>
using namespace std;
char c[]={'a','c','g','o'};
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
    int n,i1=0,i0=0;
    string s;
    cin>>n>>s;
    for(int i=0;i<8*n;i++){
        if(s[i]=='1')i1++;
        else i0++;
    }
    i1-=3*n;
    i0-=2*n;
    if(i1<0||i0<0){
        cout<<"NIE";
        return 0;
    }
    string ss={};
    for(int i=3;i>=0;i--){
        while(i1>=i&&ss.size()<n){
            ss+=c[i];
            i1-=i;
        }
    }
    cout<<ss;
    return 0;
}