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 <bits/stdc++.h>
#include <unordered_set>
using namespace std;

const int N = int(5e5) + 99;

int n, x, k;
int a[N];
string letters = "acno";

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    int k = 8*n;
    int ones = 0;
    char c;
    for (int i = 0; i <k; i++) {
        cin >> c;
        if(c=='1') ones++;
    }
    ones -= (n*3);

    if (ones < 0 || ones > 3*n) {
        cout << "NIE" << endl;
        return 0;
    }

    string s = "";
    for (int i = 0; i < n; i++) {
        if (ones > 3) {
            s += letters[3];
            ones -= 3;
        } else if (ones == 0) {
            s += letters[ones];
        } else {
            s += letters[ones];
            ones = 0;
        }
    } 
    cout << s << endl;
}