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
#include <iostream>
using namespace std;

int n, ans;
char b;
char t[7] = { ' ',' ',' ','a','c','g','o' };

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n<<3; i++) {
        cin >> b;
        ans += (b=='1' ? 1 : 0);
    }
    if (n * 3 <= ans && n*6 >= ans) {
        ans -= n * 3;
        for (int i = 0; i < n; i++) {
            if (ans >= 3) {
                cout << t[6];
                ans -= 3;
            }
            else {
                cout << t[3 + ans];
                ans = 0;
            }
        }
    }
    else
        cout << "NIE";
    return 0;
}