#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n,k,t,fst;
vector<int> v;
string s;
int main(){
cin >> n >> k >> t;
cin >> s;
reverse(s.begin(),s.end());
for(auto it:s){
fst = fst * 2 + it - '0';
}
if(k % 2 == 0){
printf("-1");
return 0;
}
printf("%d\n",(1 << n));
int _n = 2;
int _k = 1;
v = {0,1,3,2};
while(_k < k){
vector<int> nv;
for(int i = 0;i < (1 << _n);i++){
nv.push_back(v[i] ^ ((i % 2 == 0 ? 0:3) << _n));
}
for(int i = 0;i < (1 << _n);i++){
nv.push_back(((1 << _n) - 1) ^ v[(1 << _n) - 1 - i] ^ ((i % 2 == 0 ? 2:1) << _n));
}
for(int i = 0;i < (1 << _n);i++){
nv.push_back(v[i] ^ ((i % 2 == 0 ? 3:0) << _n));
}
for(int i = 0;i < (1 << _n);i++){
nv.push_back(((1 << _n) - 1) ^ v[(1 << _n) - 1 - i] ^ ((i % 2 == 0 ? 1:2) << _n));
}
_k += 2;
_n += 2;
v = nv;
}
while(_n < n){
vector<int> nv;
for(int i = 0;i < (1 << _n);i++){
nv.push_back(v[i]);
}
for(int i = 0;i < (1 << _n);i++){
nv.push_back(v[i] ^ (1 << _n));
}
for(int h = 0;h < _n;h++){
if(((v[0] >> h) & 1) != ((v[(1 << _n) - 1] >> h) & 1)){
for(int i = (1 << _n);i < (2 << _n);i++){
nv[i] ^= (1 << h);
}
break;
}
}
_n++;
v = nv;
}
/*
for(int i = 0;i < (1 << n);i++){
printf("%d ",__builtin_popcount(v[i] ^ v[(i + 1) & ((1 << n) - 1)]));
}
printf("\n");
*/
for(int i = 0;i < (1 << n);i++){
v[i] ^= fst;
for(int h = 0;h < n;h++){
printf("%d",((v[i] >> h)) & 1);
}
printf("\n");
}
printf("\n");
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Ok |
2 |
Correct |
0 ms |
364 KB |
Ok |
3 |
Correct |
1 ms |
364 KB |
Ok |
4 |
Correct |
0 ms |
364 KB |
Ok |
5 |
Correct |
1 ms |
364 KB |
Ok |
6 |
Correct |
1 ms |
364 KB |
Ok |
7 |
Correct |
1 ms |
364 KB |
Ok |
8 |
Correct |
1 ms |
364 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
488 ms |
6552 KB |
Ok |
2 |
Correct |
237 ms |
3448 KB |
Ok |
3 |
Correct |
2 ms |
364 KB |
Ok |
4 |
Correct |
1 ms |
364 KB |
Ok |
5 |
Correct |
1 ms |
364 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Ok |
2 |
Correct |
12 ms |
492 KB |
Ok |
3 |
Correct |
233 ms |
3324 KB |
Ok |
4 |
Correct |
108 ms |
1924 KB |
Ok |
5 |
Correct |
1 ms |
364 KB |
Ok |
6 |
Correct |
3 ms |
364 KB |
Ok |
7 |
Correct |
52 ms |
1164 KB |
Ok |
8 |
Correct |
1 ms |
364 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
486 ms |
6656 KB |
Ok |
2 |
Correct |
483 ms |
6556 KB |
Ok |
3 |
Correct |
486 ms |
6516 KB |
Ok |
4 |
Correct |
229 ms |
3332 KB |
Ok |
5 |
Correct |
238 ms |
3452 KB |
Ok |
6 |
Correct |
111 ms |
2052 KB |
Ok |
7 |
Correct |
109 ms |
1924 KB |
Ok |
8 |
Correct |
54 ms |
1164 KB |
Ok |
9 |
Correct |
52 ms |
1168 KB |
Ok |
10 |
Correct |
32 ms |
748 KB |
Ok |
11 |
Correct |
2 ms |
364 KB |
Ok |
12 |
Correct |
2 ms |
364 KB |
Ok |
13 |
Correct |
1 ms |
364 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
488 ms |
6552 KB |
Ok |
2 |
Correct |
237 ms |
3448 KB |
Ok |
3 |
Correct |
2 ms |
364 KB |
Ok |
4 |
Correct |
1 ms |
364 KB |
Ok |
5 |
Correct |
1 ms |
364 KB |
Ok |
6 |
Correct |
1 ms |
364 KB |
Ok |
7 |
Correct |
12 ms |
492 KB |
Ok |
8 |
Correct |
233 ms |
3324 KB |
Ok |
9 |
Correct |
108 ms |
1924 KB |
Ok |
10 |
Correct |
1 ms |
364 KB |
Ok |
11 |
Correct |
3 ms |
364 KB |
Ok |
12 |
Correct |
52 ms |
1164 KB |
Ok |
13 |
Correct |
1 ms |
364 KB |
Ok |
14 |
Correct |
486 ms |
6656 KB |
Ok |
15 |
Correct |
483 ms |
6556 KB |
Ok |
16 |
Correct |
486 ms |
6516 KB |
Ok |
17 |
Correct |
229 ms |
3332 KB |
Ok |
18 |
Correct |
238 ms |
3452 KB |
Ok |
19 |
Correct |
111 ms |
2052 KB |
Ok |
20 |
Correct |
109 ms |
1924 KB |
Ok |
21 |
Correct |
54 ms |
1164 KB |
Ok |
22 |
Correct |
52 ms |
1168 KB |
Ok |
23 |
Correct |
32 ms |
748 KB |
Ok |
24 |
Correct |
2 ms |
364 KB |
Ok |
25 |
Correct |
2 ms |
364 KB |
Ok |
26 |
Correct |
1 ms |
364 KB |
Ok |
27 |
Correct |
491 ms |
6492 KB |
Ok |
28 |
Correct |
229 ms |
3320 KB |
Ok |
29 |
Correct |
492 ms |
6528 KB |
Ok |
30 |
Correct |
25 ms |
748 KB |
Ok |
31 |
Correct |
2 ms |
364 KB |
Ok |
32 |
Correct |
12 ms |
492 KB |
Ok |
33 |
Correct |
51 ms |
1148 KB |
Ok |
34 |
Correct |
1 ms |
364 KB |
Ok |
35 |
Correct |
1 ms |
364 KB |
Ok |
36 |
Correct |
1 ms |
364 KB |
Ok |
37 |
Correct |
1 ms |
364 KB |
Ok |
38 |
Correct |
234 ms |
3512 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
231 ms |
3424 KB |
Ok |
2 |
Correct |
511 ms |
6748 KB |
Ok |
3 |
Correct |
506 ms |
6676 KB |
Ok |
4 |
Correct |
24 ms |
748 KB |
Ok |
5 |
Correct |
1 ms |
492 KB |
Ok |
6 |
Correct |
51 ms |
1128 KB |
Ok |
7 |
Correct |
483 ms |
6516 KB |
Ok |
8 |
Correct |
2 ms |
364 KB |
Ok |
9 |
Correct |
1 ms |
364 KB |
Ok |
10 |
Correct |
2 ms |
364 KB |
Ok |
11 |
Correct |
111 ms |
1892 KB |
Ok |
12 |
Correct |
231 ms |
3444 KB |
Ok |