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 <string>
using namespace std;

char tab[7];

int main() {
	ios_base::sync_with_stdio(false);
	tab[3] = 'a';
	tab[4] = 'c';
	tab[5] = 'g';
	tab[6] = 'w';
	int n;
	cin >> n;
	int cnt = 0;
	string input;
	cin >> input;
	for(int i = 0; i < 8*n; ++i) {
		if(input[i] == '1') ++cnt;
	}
	double avg = cnt * 1.0 / n;
	if(avg > 6 || avg < 3) {
		cout << "NIE" << endl;
		return 0;
	}
	for(int i = 0; i < n; ++i) {
		avg = cnt * 1.0 / (n-i);
		cout << tab[int(avg)];
		cnt -= int(avg);
	}
	return 0;
}