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
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<unordered_map>

using namespace std;

map<int, char> letters = {{3, 'a'}, {4, 'c'}, {5, 'g'}, {6, 'o'}};

int main(){
    int n, ones = 0;
    cin >> n;
    for(int i=0;i<8*n;i++){
        char x;
        cin >> x;
        if(x=='1'){
            ones++;
        }
    }
    if(ones<n*3 || ones>n*6){
        cout << "NIE" << endl;
        return 0;
    }
    while(n!=0){
        if(ones>n*5){
            cout << "o";
            ones -= 6;
        }else if(ones>n*4){
            cout << "g";
            ones -= 5;
        }else if(ones>n*3){
            cout << "c";
            ones -= 4;
        }else{
            cout << "a";
            ones -= 3;
        }
        n -=1;
    }
    cout << endl;
}