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
#include <iostream>
#include <string>
using namespace std;
int n,w,y,x,cnt;
int main(){
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    string s; cin >> s;
    //cout << n << "\n" << s << "\n";
    for(auto i : s)
        if(i == '1')
            w++;
    if(w <= 2){
        cout << "NIE\n";
        return 0;
    }
    y = (w / 3);
    if(w - y * 3 != 0 && w - y * 3 <= 2)
        y--;
    x = w - y * 3;
    cnt = y + (x ? 1 : 0);
    string res = "";
    while(cnt > n && y >= 2)
        y -= 2,cnt--,res += "o";
    if(cnt == n){
        for(int j = 0; j < y; j++)res += "a";
        if(x)
            res = res + (x == 4 ? "c" : "g");
        cout << res << "\n";
    }else
        cout << "NIE\n";
}