#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i)
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
vector<int> sen, now;
vector<bool> vis;
int n, k, t;
void pr(int x){
for(int i = n-1; i >= 0; --i)
if(x>>i&1)
printf("1");
else
printf("0");
puts("");
}
void f(int x){
if((int)now.size()==(1<<n)){
if(t==1 and __builtin_popcount(now[0]^now[(1<<n)-1])!=k)
return;
printf("%d\n", (1<<n));
tr(it, now)
pr(*it);
exit(false);
}
tr(it, sen)
if(!vis[x^*it]){
vis[x^*it]=1, now.pb(x^*it);
f(x^*it);
vis[x^*it]=0, now.pop_back();
}
}
int main(){
scanf("%d%d%d", &n, &k, &t);
string s;
cin>>s;
if(k%2==0){
puts("-1");
return 0;
}
int M=0;
for(int i = 0; i < n; ++i)
if(s[i]=='1')
M|=(1<<(n-i-1));
for(int mk = 0; mk < (1<<n); ++mk)
if(__builtin_popcount(mk)==k)
sen.pb(mk);
vis.assign((1<<n), 0);
vis[M]=1, now.pb(M);
f(M);
puts("-1");
return 0;
}
Compilation message (stderr)
lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:46:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
46 | scanf("%d%d%d", &n, &k, &t);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |