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>
using namespace std;
int N, K, T, S;
string st;
int usable[1000005];
vector<int> kdiff, ans;
void dfs(int x){
usable[x] = 0;
ans.push_back(x);
for (auto it : kdiff){
if (usable[x ^ it]){
dfs(x ^ it);
return;
}
}
}
string intToString(int x){
string r;
for (int i = 0; i < N; ++i){
r = ((x & (1 << i)) ? '1' : '0') + r;
}
return r;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> N >> K >> T;
cin >> st;
for (int i = 0; i < (int) st.size(); ++i){
S *= 2;
S += (int) (st[i]-'0');
}
for (int i = 0; i < (1 << N); ++i){
if (__builtin_popcount(i) == K){
kdiff.push_back(i);
}
usable[i] = 1;
}
dfs(S);
if ((int) ans.size() != (1 << N)){
cout << -1 << '\n';
}
else{
cout << (1 << N) << '\n';
for (auto it : ans){
cout << intToString(it) << '\n';
}
}
}
# | 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... |