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

using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    int n;
    string message;
    array<char, 6> letters = { '-', '-', 'o', 'g', 'c', 'a'};

    cin >> n >> message;

    int zeroCount = 0;
    for (char ch : message) {
        zeroCount += (ch == '0' ? 1 : 0);
    }

    if ((zeroCount < 2 * n) || (zeroCount > 5 * n)) {
        cout << "NIE";
    } else {
        int mid = zeroCount / n;
        int midPlusCount = zeroCount - mid * n;
        int midCount = mid * n - zeroCount + n;
        string result;
        result.reserve(message.length());

        result.resize(midCount, letters[mid]);
        result.resize(midCount + midPlusCount, letters[mid + 1]);
        cout << result;
    }


    return 0;
}