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

using namespace std;

string s;
string s2;
int T[3];

int main(void){
    int n;
    scanf("%d",&n);
    cin >> s;
    for(int i = 0 ; i < s.size();i++){
        if(s[i] == '0')
            T[0]++;
        else
            T[1]++;
    }
    T[0] -= 2*n;
    T[1] -= 3*n;
    if(T[0] < 0 || T[1] < 0){
        printf("NIE");
        return 0;
    }
    for(int i = 1; i <= n;i++){
        if(T[1] >= 3){
            T[1] -= 3;
            s2.push_back('o');
        }else if(T[1] >= 2){
            T[1] -= 2;
            s2.push_back('g');
        }else if(T[1] >= 1){
            T[1] -= 1;
            s2.push_back('c');
        }else{
            s2.push_back('a');
        }
    }
    cout << s2;


    return 0;
}