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

#define boost                     \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)

string let = "axyw";

int main() {
    boost;
    int n;
    string s;
    cin >> n >> s;

    int ones_count = 0;
    for(char c : s) ones_count += (c == '1');

    if (ones_count < 3 * n || ones_count > 6 * n)
    {
        cout << "NIE\n";
        return 0;
    }

    int min_letter = ones_count / n;
    int n_bigger = ones_count % n;

    for (int i = 0; i < n - n_bigger; ++i)
        cout << let[min_letter - 3];
    for (int i = 0; i < n_bigger; ++i)
        cout << let[min_letter - 2];
    cout << '\n';

    return 0;
}