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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define ST first
#define ND second
#define SIZE(a) ((int)a.size())


int main() {
    ios_base::sync_with_stdio(0);
    int n;
    string s;
    int count = 0;
    cin >> n >> s;
    for(char c : s) {
        if(c == '1') {
            count++;
        }
    }
    count-=3*n;
    map<int, char> m {
        {0, 'a'},
        {1, 'c'},
        {2, 'g'},
        {3, 'o'}
    };
    if(count < 0 || count > 3*n) {
        cout << "NIE\n";
    } else {
        int freq = count/n;
        int r = count - n*freq;
        for(int i=0; i < n-r; i++) {
            cout << m[freq];
        }
        for(int i=0; i < r; i++) {
            cout << m[freq+1];
        }
        cout << "\n";
    }
}