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

char reps[] = "$$$bcmo";

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    string str;
    cin >> n >> str;

    int zeros = 0, ones = 0;
    for(char c : str)
        if (c == '0')
            zeros++;
        else
            ones++;
    
    if (ones < 3 * n || ones > 6 * n)
        cout << "NIE";
    else while(n) {
        int now_ones;
        if (ones == 3 * n)
            now_ones = 3;
        else if (ones <= 4 * n)
            now_ones = 4;
        else if (ones <= 5 * n)
            now_ones = 5;
        else
            now_ones = 6;
        
        cout << reps[now_ones];
        ones -= now_ones;
        zeros -= 8 - now_ones;
        n--;
    }

    cout << "\n";
    return 0;
}