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

using namespace std;

const int JEDEN = 49;

int n;
string s;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int jed = 0;

	cin >> n;
	cin >> s;

	for (int i = 0; i < s.size(); ++i) {
        if (s[i] == JEDEN) jed++;
	}

	if (jed < 3 * n || jed > 6 * n) {
        cout << "NIE\n";
        return 0;
	}

    int baza = jed / n;
    int resz = jed % n;

    string out = "";

    for (int i = 1; i <= n; ++i) {
        int znak = baza;
        if (0 < resz--) znak++;
        switch (znak) {
            case 3: out += 'a'; break;
            case 4: out += 'c'; break;
            case 5: out += 'g'; break;
            case 6: out += 'o'; break;
        }
    }

    cout << out << '\n';
}