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
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;

#define INF 8000008

long long n,i;
char tab[INF];
char res[INF];

int main()
{
  scanf("%lld", &n);
  scanf("%s", tab);
  long long one=0;
  for(i=0;i<8*n;i++){
    if(tab[i]=='1') one++;
  }
  //printf("%lld\n", n);
  //printf("%s\n", tab);
  long long zero=8*n-one;
  long long diff = zero-one;
  //printf("z:%lld je:%lld -> %lld\n",zero,one, diff);
  if(diff>=0) {
    if(diff%2==1) {
      printf("NIE\n");
      return 0;
    }
    if(diff/2>n) {
      printf("NIE\n");
      return 0;
    }
    for(i=0;i<(zero-one)/2;i++) {
      res[i]='a';
    }
    for(;i<n;i++) {
      res[i]='c';
    }
    res[n]=0;
    printf("%s\n",res);
  } else {
    diff*=-1;
    if(diff%2==1) {
      printf("NIE\n");
      return 0;
    }
    if(diff/4>n || (diff%4==2 && diff/4==n)) {
      printf("NIE\n");
      return 0;
    }
    i=0;
    while(diff>=4) {
      res[i++]='o';
      diff-=4;
    }
    while(diff>=2) {
      res[i++]='g';
      diff-=2;
    }
    while(i<n){
      res[i++]='c';
    }
    res[n]=0;
    printf("%s\n",res);
  }
  return 0;
}