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 <iostream>
#include <algorithm>
#include <vector>
#include <fstream>

using namespace std;

void solve(){
	int n,N;		
	string arr;
	cin >> n;
	N = 8 * n;
	cin >> arr;

	int zeros = 0;
	int ones = 0;
	for (int i = 0; i <N; i++)
		if (arr[i] == '1') ones++;
		else zeros++;
	
	string ans;
	//wykonaj n operacji/ doklejenia n liczb
	for (int i = 0; i < n; i++) {
		if (ones >= zeros + 4) {
			ones -= 6;
			zeros -= 2;
			ans += 'o';
			continue;
		}

		if (ones == zeros + 2) {
			ones -= 5;
			zeros -= 3;
			ans += 'n';
			continue;
		}

		if (ones == zeros) {
			ones -= 4;
			zeros -= 4;
			ans += 'c';
			continue;
		}

		if (ones + 2 <= zeros) {
			ones -= 3;
			zeros -= 5;
			ans += 'a';
			continue;
		}
	}
	if (zeros == 0 && ones == 0)	cout << ans << endl;
	else cout << "NIE";
}

int main() {
	solve();
	return 0;
}