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
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cstdio>
#include <iostream>

using namespace std;
string s;
int n, zero=0, one=0;
char c[100006];
int main()
{
    cin>>n;
    cin>>s;
    for(int i=0; i<s.length(); i++){
        if(s[i]=='0'){
            zero++;
        }else{
            one++;
        }
    }
    if(zero<2*n || one<3*n){
        printf("NIE\n");
        return 0;
    }else{
        zero==(2*n);
        one-=(3*n);
        for(int i=1; i<=n; i++){
            c[i]=104;
            if(one>2){
                c[i]+=7;
                one-=3;
            }else{
                if(one>1){
                    c[i]+=3;
                    one-=2;
                } else {
                        if(one>0){
                            c[i]++;
                            one--;
                        }
                        
                    }
                
            }
        }
        for(int i=1; i<=n; i++){
            printf("%c", c[i]);
        }
        printf("\n");
    }

    return 0;
}