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

using namespace std;

char chrs[] = {'A', 'a', 'c', 'g', 'o', 'z'}; //padding

int main() {
    int n;
    cin >> n;

    int ones = 0;
    char c;

    while((c = getchar()) < '0');
    do {
        if(c == '1') ones++;
    } while((c = getchar()) >= '0');

    ones -= 2*n;

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

    for(int i = n; i > 0; i--) {
        int k = ones / i;
        ones -= k;
        putchar(chrs[k]);
    }

    putchar('\n');

    return 0;
}