#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
string s;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, jed = 0;
cin>>n>>s;
n *= 8;
for(int i=0; i<n; i++) if(s[i] == '1') jed++;
if(8 * jed < 3 * n || 8 * jed > 6 * n)
{
cout<<"NIE";
return 0;
}
while(jed > 0 && 8 * (jed - 3) >= 3 * n)
{
cout<<"w";
jed -= 6;
n -= 8;
}
if(jed % 3 == 2)
{
cout<<"k";
jed -= 5;
n -= 8;
}
if(jed % 3 == 1)
{
cout<<"c";
jed -= 4;
n -= 8;
}
while(jed > 0)
{
cout<<"b";
jed -= 3;
n -= 8;
}
return 0;
}
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 | #include<bits/stdc++.h> #define fi first #define se second #define pb push_back using namespace std; string s; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, jed = 0; cin>>n>>s; n *= 8; for(int i=0; i<n; i++) if(s[i] == '1') jed++; if(8 * jed < 3 * n || 8 * jed > 6 * n) { cout<<"NIE"; return 0; } while(jed > 0 && 8 * (jed - 3) >= 3 * n) { cout<<"w"; jed -= 6; n -= 8; } if(jed % 3 == 2) { cout<<"k"; jed -= 5; n -= 8; } if(jed % 3 == 1) { cout<<"c"; jed -= 4; n -= 8; } while(jed > 0) { cout<<"b"; jed -= 3; n -= 8; } return 0; } |
English