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
// Example program
#include <iostream>
#include <string>

#define MAXN 800008

int main()
{
  // char znak[10] = {'-', '-', '-', 'p', 'x', 'z', 'w'};
  char input[MAXN];
  int n;
  scanf("%d", &n);
  scanf("%s", input);
  int ile_1 = 0;
  for (int i = 0; i < 8*n; i++) {
    if(input[i] == '1') {
       ile_1++;   
    }
  }
  if ((ile_1 < 3*n) || (ile_1 > 6*n)) {
    printf("NIE\n");   
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if ((ile_1 - 6) >= 3*(n - i - 1)) {
        printf("w");   
        ile_1 -= 6;
    }
    else if ((ile_1 - 5) >= 3*(n - i - 1)) {
        printf("z");   
        ile_1 -= 5;   
    }
    else if ((ile_1 - 4) >= 3*(n - i - 1)) {
        printf("x");   
        ile_1 -= 4;   
    }
    else {
        printf("p");   
        ile_1 -= 3;   
    }
  }
  printf("\n");
}