#include <bits/stdc++.h>
#define ss second
#define ff first
#define pb push_back
//Igor Rostkowski
using namespace std;
int n,z,j;
bool en;
string w;
char c;
void fun(string h,int x,int y)
{
if(en)
{
return;
}
if(x==0&&y==0)
{
w=h;
en=1;
}
else
{
if(x-5>=0&&y-3>=0)
{
fun(h+'a',x-5,y-3);
}
if(x-4>=0&&y-4>=0)
{
fun(h+'c',x-4,y-4);
}
if(x-3>=0&&y-5>=0)
{
fun(h+'k',x-3,y-5);
}
if(x-2>=0&&y-6>=0)
{
fun(h+'w',x-2,y-6);
}
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
w="NIE";
cin>>n;
for(int i=0;i<n*8;i++)
{
cin>>c;
if(c=='0')
{
z++;
}
else
{
j++;
}
}
fun("",z,j);
cout<<w;
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 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 76 77 78 79 80 | #include <bits/stdc++.h> #define ss second #define ff first #define pb push_back //Igor Rostkowski using namespace std; int n,z,j; bool en; string w; char c; void fun(string h,int x,int y) { if(en) { return; } if(x==0&&y==0) { w=h; en=1; } else { if(x-5>=0&&y-3>=0) { fun(h+'a',x-5,y-3); } if(x-4>=0&&y-4>=0) { fun(h+'c',x-4,y-4); } if(x-3>=0&&y-5>=0) { fun(h+'k',x-3,y-5); } if(x-2>=0&&y-6>=0) { fun(h+'w',x-2,y-6); } } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); w="NIE"; cin>>n; for(int i=0;i<n*8;i++) { cin>>c; if(c=='0') { z++; } else { j++; } } fun("",z,j); cout<<w; return 0; } |
English