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

using namespace std;

int main(){

    int n;
    cin>>n;

    string a;
    cin>>a;
    
    int onecnt = 0;
    string ans = "";

    for(int i=0; i<8*n; i++){
        if(a[i]=='1')
            onecnt++;
    }
    bool is = false;
    int min = 3*n;
    int max = 6*n;
    vector<char> V = {'a', 'c', 'g', 'o'};

    if(onecnt < min || onecnt > max)
        cout<<"NIE"<<endl;
    else{
        while(max>onecnt){
            for(int i=3; i>0 && max>=onecnt; i--){
                if(max==onecnt){
                    ans+=V[i];
                    is = true;
                    break;
                }
                max--;
            }
            if(!is)
                ans+='a';
        }

        int l = ans.length();
        for(int i=0; i<n-l; i++)
            ans+='o';

        cout<<ans<<endl;
    }

    

    return 0;
}