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

using namespace std;

int main() {
    int n;
    cin>>n;
    char x;
    int ile = 0;
    for(int i=0;i<8*n;i++) {
        cin>>x;
        if(x=='1') {
            ile++;
        }
    }
    if(ile < 3*n || ile > 6*n) {
        cout<<"NIE\n";
    }
    else {
        int tab[n];
        fill_n(tab,n,2);
        ile -= 2*n;
        int ind=0;
        while(ile > 0) {
            if(ind>=n) {
                ind = 0;
                continue;
            }
            tab[ind]++;
            ind++;
            ile--;
        }
        for(int i=0;i<n;i++) {
            if(tab[i]==3)
                cout<<'a';
            else if(tab[i] == 4)
                cout<<'c';
            else if(tab[i] == 5)
                cout<<'g';
            else if(tab[i] == 6)
                cout<<'w';
            else
                cout<<"ERROR\n";
        }
    }
}