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
#include <iostream>
#include <string>

using namespace std;

void print(int n_first, char first, int n_second, char second) {

    for (auto i = 0; i < n_first; i++) {
        cout << first;
    }
    for (auto i = 0; i < n_second; i++) {
        cout << second;
    }
}

int main() {
    std::ios::sync_with_stdio(false);

    int n, num_of_ones = 0;
    string s;

    cin >> n;
    cin >> s;

    for (auto i = 0; i < s.size(); i++) {
        if (s[i] == '1') num_of_ones++;
    }

    if (num_of_ones >= n * 3 && num_of_ones <= n * 6) {
        int x = (num_of_ones - n * 3) / n, y = (num_of_ones - n * 3) % n;

        switch (x) {
            case 0: print(n - y, 'a', y, 'c'); break;
            case 1: print(n - y, 'c', y, 'z'); break;
            case 2: print(n - y, 'z', y, 'o'); break;
            case 3: print(n - y, 'o', y, 'o'); break;
        }

    } else {
        cout << "NIE";
    }

    return 0;
}