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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#define _CRT_SECURE_NO_WARNINGS 1
#define _WINSOCK_DEPRECATED_NO_WARNINGS 1

#include <iostream>
#include <string>
using namespace std;

int wynik[123456];

int main()
{    
    int n;
    scanf("%d", &n);
    string str;
    getline(std::cin, str); 

    long long jedyneczki = 0;
    for(int i = 0; i < n*8; ++i)
    {  
        char p;
        scanf("%c", &p, 1);

        if (p == '1')
        {
            jedyneczki++;
        }
    }

    long long minimum = n * 3;
    long long maximum = n * 6;
    
    if ((jedyneczki < minimum || jedyneczki > maximum))
    {
        printf("NIE");
        return 0;
    }

    jedyneczki -= n * 2;
    for (int i = 3; i < 7; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            if (jedyneczki == 0)
            {
                break;
            }

            wynik[j] = i;
            jedyneczki--;
        }
    }

    for (int j = 0; j < n; ++j)
    {
        long long nn = wynik[j];
        switch (nn)
        {
            case 3:
                printf("a");
                break;
            case 4:
                
                printf("c");
                break;
            case 5:
              
                printf("g");
                break;
            case 6:
                
                printf("o");
                break;
        }       
    }    
}