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
#include<bits/stdc++.h>
using namespace std;

char val[4] = {'a','c','g','o'};

char get_type(int &obec,int &ile) {

    if(obec == ile)
        return val[0];
    if(ile - obec > 3) {
        obec +=3;
        return val[3];
    }
    int t = ile - obec;
    obec += ile - obec;
    return val[t];
}

int main() {

    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    string in;
    cin >> in;
    int ile = 0;
    for(auto t:in) {
        if(t == '1')
            ile++;
    }
    if(ile < 3*n || ile > 6*n)
        cout << "NIE";
    else{
        int obec = 3*n;
        for(int k=0;k<n;k++) {
            cout << get_type(obec,ile);
        }

    }

}