This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#include <bits/stdc++.h>
#include <bits/stdc++.h>
#define f first
#define s second
#define vec vector
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pw(x) (1LL<<(x))
#define sz(x) (int)(x).size()
#define fast_izho ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define m_p make_pair
using namespace std;
template <class T> bool umin(T &a,const T &b){return (a>b?a=b,1:0);}
template <class T> bool umax(T &a,const T &b){return (a<b?a=b,1:0);}
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
auto rng=bind(uniform_int_distribution<int>(1,1e7),mt19937(time(0)));
signed main(){
fast_izho;
// ifstream cin("input.txt");
int n,k,t;
cin>>n>>k>>t;
n=pw(n);
vec<int> base,elim;
for(int i=0;i<n;i++){
if(__builtin_popcount(i)==k){
int x=i;
for(auto &z : elim) x=min(x,x^z);
if(x){
base.pb(i);
elim.pb(x);
}
}
}
if(sz(base)!=(__builtin_popcount(n-1))){
cout<<-1;
return 0;
}
int xr=0;
vec<int>ans;
ans.pb(0);
for(int i=1;i<n;i++){
// cout<<xr<<' ';
xr^=base[31-__builtin_clz(i&-i)];
ans.pb(xr);
// cout<<xr<<'\n';
}
// int s;
string s;
cin>>s;
int x=0;
for(auto &z : s)
x*=2,x+=(z-'0');
// int x=stoi(s);
// cin>>s;
// cout<<x<<endl;
// cout<<ans[0]<<endl;
for(auto &z : ans)
z^=x;
for(int i=0;i<n;i++){
int j=(i+1)%n;
if(i==n-1 && t==0) continue;
if(__builtin_popcount(ans[i]^ans[j])!=k){
cout<<-1;
return 0;
}
}
int need=__builtin_popcount(n-1);
cout<<n<<'\n';
for(auto &z : ans){
string me;
for(int j=0;j<need;j++){
me+=(pw(j)&z?'1':'0');
}
reverse(all(me));
cout<<me<<'\n';
}
return 0;
}
/*
5 1
0 1 1 3 2
1 3
*/
# | 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... |