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
// #include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

int main()
{
    FAST int n;
    cin >> n;
    string s;
    int ones = 0;
    cin >> s;
    for (int i = 0; i < 8 * n; i++)
    {
        if (s[i] == '1')
        {
            ones++;
        }
    }

    if ((ones >= n * 3) && (ones <= n * 6))
    {
        int over = ones - n * 3;
        for (int i = 0; i < n; i++)
        {
            switch (over)
            {
            case 0:
                cout << "p";
                break;
            case 1:
                cout << "q";
                over--;
                break;
            case 2:
                cout << "s";
                over -= 2;
                break;
            default:
                cout << "w";
                over -= 3;
                break;
            }
        }
        cout << endl;
    }
    else
    {
        cout << "NIE" << endl;
    }

    return 0;
}