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
// {3: 'p', 4: 'x', 5: 'z', 6: 'w'}
#include<cstdio>

char input[1000*1000];
char res[1000*1000];

int main() {
    int n;
    scanf("%i", &n);
    scanf("%s", input);
    
    int ones = 0;
    for (int i = 0; i < n*8; ++i)
        if (input[i] == '1')
            ones++;
    
    int zeros = 8*n - ones;
    
    for (int i = 0; i < 3*n; ++i)
        res[i] = 0;
    
    if (ones < 3*n or ones > 6*n) {
        printf("NIE\n");
        return 0;
    }
    
    int sixes = (ones) / 3 - n;
    
    ones -= 6*sixes;
    zeros -= 2*sixes;
    n -= sixes;
    
    int excess = ones - 3*n;
    int threes = n;
    
    if (excess == 0) {
    } else if (excess == 1) {
        printf("x");
        threes--;
    } else if (excess == 2) {
        printf("z");
        threes--;
    } else {
        return 1;
    }
    
    for (int i = 0; i < threes; ++i)
        printf("p");
    for (int i = 0; i < sixes; ++i)
        printf("w");
    
    printf("\n");

    return 0;
}