#include <bits/stdc++.h>
using namespace std;
string bS;
int N, K, S, T;
vector <int> v, ans;
vector <int> build(int N){
if (N == 1){
vector <int> ans = {0, 1};
return ans;
}
vector <int> a = build(N-1);
for (int i = 0; i < (1<<(N-1)); i++){
a.push_back((1<<(N-1))+a[(1<<(N-1))-1-i]);
}
return a;
}
vector <int> solve(int N, int K){
if (K%2 == 0) return {};
if (K == 1) return build(N);
vector <int> tmp = solve(N-2, K-2), ans(0);
for (int i = 0; i < (1<<N); i++){
if (i == 0){
ans.push_back(0);
continue;
}
if (i&1) ans.push_back(ans.back()^((1<<K)-1));
else if (i&3) ans.push_back(ans.back()^((1<<N)-(1<<(N-K))));
else ans.push_back(ans.back()^tmp[i>>2]^tmp[(i>>2)-1]^((1<<N)-(1<<(N-2))));
}
return ans;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> N >> K >> T >> bS;
for (int i = 0; i < N; i++)
if (bS[i] == '1') S += (1<<(N-1-i));
vector <int> ans = solve(N, K);
if (ans.empty()){
cout << "-1\n";
return 0;
}
cout << (1<<N) << '\n';
for (int &x : ans){
x ^= S;
for (int i = N-1; i >= 0; i--)
cout << ((x>>i)&1);
cout << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
The values in the output sequence are not pairwise distinct! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Ok |
2 |
Correct |
0 ms |
348 KB |
Ok |
3 |
Correct |
0 ms |
348 KB |
Ok |
4 |
Correct |
0 ms |
348 KB |
Ok |
5 |
Correct |
1 ms |
348 KB |
Ok |
6 |
Correct |
1 ms |
348 KB |
Ok |
7 |
Correct |
1 ms |
348 KB |
Ok |
8 |
Correct |
1 ms |
344 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
150 ms |
6380 KB |
Ok |
2 |
Correct |
71 ms |
3276 KB |
Ok |
3 |
Correct |
1 ms |
344 KB |
Ok |
4 |
Correct |
0 ms |
344 KB |
Ok |
5 |
Correct |
0 ms |
348 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
The values in the output sequence are not pairwise distinct! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
153 ms |
6392 KB |
The values in the output sequence are not pairwise distinct! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
150 ms |
6380 KB |
Ok |
2 |
Correct |
71 ms |
3276 KB |
Ok |
3 |
Correct |
1 ms |
344 KB |
Ok |
4 |
Correct |
0 ms |
344 KB |
Ok |
5 |
Correct |
0 ms |
348 KB |
Ok |
6 |
Incorrect |
1 ms |
348 KB |
The values in the output sequence are not pairwise distinct! |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
86 ms |
3360 KB |
The values in the output sequence are not pairwise distinct! |
2 |
Halted |
0 ms |
0 KB |
- |