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
#include <iostream>
#include <map>
#define ll long long
#define pb push_back
using namespace std;

const int MAXW = 3000;
const int mod = 1e9 + 7;

int n;
string s;
string x;
int ile;
map<int, char> t;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    cin >> s;
    t[3] = 'a';
    t[4] = 'c';
    t[5] = 'g';
    t[6] = 'o';
    for (auto c : s) if (c == '1') ile++;
    if (ile >= 3*n && ile <= 6*n){
        while (ile > 0) {
            for (int i = 3; i <= 6; i++){
                if ( (ile-i) >= 3*(n-1) && (ile-i) <= 6*(n-1) ){
                    x += t[i]; ile -= i; n--;
                    break;
                }
            }
        }
        cout << x;
    }
    else cout << "NIE";
    
    
}