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
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

char t[] = {0,0,'a','c','g','w'};
char s[1000010];
char s2[100010];
int main()
{
    int n;
    cin >> n;
    cin >> s;
    int ij=0;
    for (int i=0;i<8*n;i++) ij += (s[i]=='1' ? 1 : 0);

    if (ij < 3*n || ij > 6*n)
    {
        cout << "NIE" << endl;
        return 0;
    }
    int p = ij/n;
    int x = p*n+n-ij;
    for (int i=0;i<x;i++) s2[i]=t[p-1];
    for (int i=x;i<n;i++) s2[i]=t[p];
    s2[n]=0;
    cout << s2 << endl;
    //p*x + (p+1)*(n-x) = ij;
    //pn+n-x=ij pn+n-ij=x

}