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
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    int n;
    cin>>n;
    string wejscie;
    cin>>wejscie;
    int ile[2];
    ile[0]=0;
    ile[1]=0;
    int licz=8*n;
    int p=0;
    int poz=0;
    string wyn="";
    for (int i=0;i<licz;i++){
        poz=(int)wejscie[i]-48;
        p=ile[poz];
        ile[poz]=p+1;
    }
    if(ile[0]>ile[1]){
        if(ile[0]*3>ile[1]*5){
            cout<<"NIE";
            return 0;
        }
    }
    else{
        if(ile[0]*6<ile[1]*2){
            cout<<"NIE";
            return 0;
        }
    }
    //cout<<ile[0]<<"   "<<ile[1]<<endl;
    if(ile[0]>=ile[1]){
        while(ile[0]-ile[1]>=2){
            wyn=wyn+'a';
            ile[0]=ile[0]-5;
            ile[1]=ile[1]-3;

        }
        while(ile[0]>0){
            wyn=wyn+'x';
            ile[0]=ile[0]-4;
        }
    }
    else{
        while(ile[1]-ile[0]>=4){
            wyn=wyn+'o';
            ile[0]=ile[0]-2;
            ile[1]=ile[1]-6;

        }
        //cout<<ile[0]<<"   "<<ile[1]<<endl;
        //cout<<ile[1]-ile[0]<<endl;
        if(ile[1]-ile[0]==2){
            wyn=wyn+'m';
            ile[0]=ile[0]-3;
            ile[1]=ile[1]-5;

        }
        if(ile[1]-ile[0]==-2){
            wyn=wyn+'a';
            ile[0]=ile[0]-5;
            ile[1]=ile[1]-3;
        }
        while(ile[1]>0){
            wyn=wyn+'x';
            ile[1]=ile[1]-4;
        }
    }
cout<<wyn;
return 0;
}