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
#include <bits/stdc++.h>
using namespace std;
int main()
{
    /*ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);*/
    int n;
    cin>>n;
    char c;
    int m=0;
    for(int i=0;i<8*n;i++)
    {
        cin>>c;
        if(c=='1')
            m++;
    }
    int h;
    if((m<=6*n)&&(3*n<=m))
    {
        for(int i=0;i<n;i++)
        {
        for(h=3;h<=6;h++)
        {
            if((m-h<=6*(n-i-1))&&(3*(n-i-1)<=m-h))
            {
                break;
            }
        }
        m-=h;
        if(h==3)
            cout<<"a";
        if(h==4)
            cout<<"c";
        if(h==5)
            cout<<"k";
        if(h==6)
            cout<<"w";
        }
    }
    else
    {
        cout<<"NIE\n";
    }
}