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
/***********PA 2021***********/
/******Autor: Jakub Bąba******/

#include <bits/stdc++.h>
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n; string ciag;
  cin >> n >> ciag;

  int ilosc = count(ciag.begin(), ciag.end(), '1');

  ilosc -= 3*n;
  if (ilosc<0 || ilosc>3*n)
    cout << "NIE";
  else
  {
    while(ilosc>=3)
    {
      cout << 'o';
      n--; ilosc -= 3;
    }
    if (n>0)
    {
      if (ilosc==2)
        cout << 'g';
      else if (ilosc==1)
        cout << 'c';
      else if (ilosc==0)
        cout << 'a';
      n--;
    }
    while (n>0)
    {
      cout << 'a';
      n--;
    }
  }

  return 0;
}