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
45
46
47
48
#include <bits/stdc++.h>
#define thicc(boi) boi.size()
#define magiczne ios_base::sync_with_stdio(0);
#define linijki cin.tie(NULL);

using namespace std;

int main()
{
    magiczne linijki;
    int n, ones = 0;
    string boi;
    cin >> n;
    cin >> boi;
    for (auto ch : boi)
    	if (ch == '1')
    		ones++;
	if (3*n <= ones and ones <= 6*n)
	{
		while (ones - 6 >= 3*(n - 1))
		{
			cout << 'w';
			ones -= 6;
			n--;
		}
		while (ones - 5 >= 3*(n - 1))
		{
			cout << 'z';
			ones -= 5;
			n--;
		}
		while (ones - 4 >= 3*(n - 1))
		{
			cout << 'x';
			ones -= 4;
			n--;
		}
		while (ones - 3 >= 3*(n - 1) and ones != 0)
		{
			cout << 'd';
			ones -= 3;
			n--;
		}
		cout << '\n';
	}
	else cout << "NIE\n";
    return 0;
}