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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    char s[n];
    string input;
    int zeros=0, ones=0;
    cin>>input;
    for(int i=0;i<8*n;i++)
    {
        if(input[i]=='0')
            zeros++;
        else
            ones++;
    }
    if(ones*5>=zeros*3 and zeros*6>=ones*2)
    {
        int maxLetter=0;
        int ones5Letter=0;
        int minLetter=0;
        int zeros5Letter=0;
        while(ones>=zeros+4)
        {
            maxLetter++;
            ones-=6;
            zeros-=2;
        }
        while(ones>=zeros+2)
        {
            ones5Letter++;
            ones-=5;
            zeros-=3;
        }
        while(zeros>=ones+2)
        {
            minLetter++;
            ones-=3;
            zeros-=5;
        }
        int equalLetter = n-maxLetter-minLetter-ones5Letter;    
        char maxLetterChar = 'w';
        char minLetterChar='a';
        char ones5LetterChar = 'z';
        char equalLetterChar = 'x';
        for(int i=0;i<maxLetter;i++)
            s[i]=maxLetterChar;
        for(int i=maxLetter;i<maxLetter+minLetter;i++)
            s[i]=minLetterChar;
        for(int i=maxLetter+minLetter;i<maxLetter+minLetter+ones5Letter;i++)
            s[i]=ones5LetterChar;
        for(int i=maxLetter+minLetter+ones5Letter;i<n;i++)
            s[i]=equalLetterChar;
        for(int i=0;i<n;i++)
            cout<<s[i];
        cout<<endl;
    }
    else
    {
        cout<<"NIE"<<endl;
    }
    return 0;
}