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
#include <bits/stdc++.h>

using std::cout;
using std::cin;
using std::ios_base;
using std::string;
using std::sort;
using std::max;
using std::min;
using std::vector;
using std::priority_queue;
using std::stack;
using std::endl;
using std::fixed;

#define be_faster_please ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long

int main()
{
    be_faster_please;
    char tab[4] = {'a', 'c', 'g', 'o'};
    int n;
    cin >> n;
    string s;
    cin >> s;
    int licz = 0;
    for(int i = 0;i < s.size(); i++)
        if (s[i] == '1')
            licz++;
    if (licz < 3 * n || licz > 6 * n)
        cout << "NIE";
    else
    {
        licz -= 2*n;
        int c = 0;
        while(licz > 0)
        {
            licz -= n;
            if (licz < n)
            {
            //    cout << licz << "\n";
                for(int i = 0; i < n ;i++)
                {
                    if(licz > 0)
                    {
                        licz--;
                        cout << tab[c + 1];
                    }
                    else
                        cout << tab[c];
                }
             //   cout << licz;
            }
            c++;
        }
    }
    return 0;
}