1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
string A = "---acgo-";

int main() {
    int n, k = 0;
    string slowo;

    cin >> n;
    cin >> slowo;
    for (int i = 0; i < slowo.size(); i++) if (slowo[i] == '1') k++;
    if (k < 3 * n || k > 6 * n) cout << "NIE";
    else {
        int d = k / n, r = k % n;
        for (int i = 0; i < r; i++) cout << A[d + 1];
        for (int i = 0; i < n - r; i++) cout << A[d];
    }
    return 0;
}