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
65
66
67
68
69
70
71
72
73
74
75
#include <bits/stdc++.h>
using namespace std;
int zlicz_bity(char a){
    int w=0;
    for (int i=0;i<8;i++){
        if (a & ((char)(1<<i))){
            w++;
        }
    }
    return w;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    vector <int > tmp;
    for (char a= 'a'; a<='z';a++){
        tmp.push_back(zlicz_bity(a));
    }
    sort(tmp.begin(),tmp.end());
    unique(tmp.begin(),tmp.end());

    for (int i=0;i+1<tmp.size();i++){
        //cout << tmp[i];
        if(tmp[i+1]<tmp[i]){
            break;
        }
    }
   //cout << endl;
    //z wczesniejszych obliczen wiem, ze suma liczby bitow dla liczb od a do z to od 3 do 6
    char znaki_dla_bitow[7];

    for (char a= 'a'; a<='z';a++){
        znaki_dla_bitow[zlicz_bity(a)]=a;
    }

    int n;
    cin >> n;
    int ile_bitow=0;
    int ile_liter=0;
    for (int i=0;i<8*n;i++){
        char tmp;
        cin >> tmp;
        ile_bitow += (tmp=='1');
    }
    int t_ile_bitow[n];
    for (int i=0;i<n;i++){
        t_ile_bitow[i]=3;
        ile_bitow-=3;
    }
    if (ile_bitow<0){
        cout << "NIE"<<endl;
        return 0;
    }
    for (int i=0;i<n;i++){
        if (ile_bitow>3){
            t_ile_bitow[i]+=3;
            ile_bitow-=3;
        }else{
            t_ile_bitow[i]+=ile_bitow;
            ile_bitow=0;
            break;
        }
    }
    if (ile_bitow>0){
        cout << "NIE"<<endl;
        return 0;
    }
    for (int i=0; i<n;i++){
        cout << znaki_dla_bitow[t_ile_bitow[i]];
    }
    cout << endl;



}