#include <bits/stdc++.h>
using namespace std;
#define flipbit(x, i) x ^= (1<<(i))
const int a[] = {0, 7, 9, 2, 5, 8, 3, 4, 10, 1, 6, 11, 12, 16, 23, 13, 17, 22, 15, 19, 20, 14, 18, 21, 24, 31, 39, 32, 43, 25, 30, 38, 33, 42, 27, 28, 36, 35, 40, 26, 29, 37, 34, 41, 46, 50, 53, 44, 48, 55, 45, 49, 54, 59, 60, 47, 57, 62, 51, 61, 58, 52, 63, 56};
const int b[] = {0, 1, 3, 2, 6, 7, 5, 4};
string bS;
int N, K, S, T;
vector <int> v, ans;
int cnt[262144];
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;
}
void show(int x){
for (int i = N-1; i >= 0; i--)
cout << ((x>>i)&1);
cout << endl;
}
vector <int> build3(int N){
if (N == 6){
vector <int> ans(0);
for (int i = 0; i < 64; i++) ans.push_back(a[i]);
return ans;
}
vector <int> tmp = build3(N-3), ans = tmp;
for (int i = 1; i < 8; i++){
int x = ans.back()&((1<<(N-3))-1);
x ^= (1<<(N-4))+(1<<(N-5));
for (int j = 0; j < (1<<(N-3)); j++)
ans.push_back((b[i]<<(N-3))+(x^tmp[j]));
}
return ans;
}
int main(){
// freopen("LYUBOYN.inp", "r", stdin);
// freopen("LYUBOYN.out", "w", stdout);
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));
v = build(N);
ans.clear();
ans.push_back(S);
for (int i = 1; i < (1<<N); i++){
ans.push_back(ans[i-1]);
for (int j = 0; j < N; j++)
if (((v[i]^v[i-1])>>j)&1){
for (int t = 0; t < K; t++)
flipbit(ans[i], (j+t)%N);
}
}
bool ok = 1;
for (int x : ans){
if (cnt[x]){
ok = 0;
break;
}
cnt[x]++;
}
if (ok){
cout << (1<<N) << '\n';
for (int x : ans){
for (int i = N-1; i >= 0; i--)
cout << ((x>>i)&1);
cout << '\n';
}
return 0;
}
if (K != 3 || N == 3){
cout << "-1\n";
return 0;
}
ans = build3(N);
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 |
0 ms |
344 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Ok |
2 |
Correct |
21 ms |
3636 KB |
Ok |
3 |
Correct |
6 ms |
2144 KB |
Ok |
4 |
Correct |
0 ms |
348 KB |
Ok |
5 |
Correct |
0 ms |
348 KB |
Ok |
6 |
Correct |
1 ms |
348 KB |
Ok |
7 |
Correct |
1 ms |
348 KB |
Ok |
8 |
Correct |
8 ms |
1888 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
171 ms |
8528 KB |
Ok |
2 |
Correct |
80 ms |
4280 KB |
Ok |
3 |
Correct |
1 ms |
348 KB |
Ok |
4 |
Correct |
0 ms |
348 KB |
Ok |
5 |
Correct |
0 ms |
348 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Ok |
2 |
Correct |
5 ms |
604 KB |
Ok |
3 |
Correct |
78 ms |
4272 KB |
Ok |
4 |
Correct |
39 ms |
2384 KB |
Ok |
5 |
Correct |
1 ms |
348 KB |
Ok |
6 |
Correct |
1 ms |
348 KB |
Ok |
7 |
Correct |
18 ms |
1496 KB |
Ok |
8 |
Correct |
0 ms |
348 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
172 ms |
8528 KB |
Ok |
2 |
Correct |
169 ms |
8516 KB |
Ok |
3 |
Correct |
178 ms |
8676 KB |
Ok |
4 |
Correct |
82 ms |
4492 KB |
Ok |
5 |
Correct |
80 ms |
4340 KB |
Ok |
6 |
Correct |
39 ms |
2388 KB |
Ok |
7 |
Correct |
39 ms |
2388 KB |
Ok |
8 |
Correct |
19 ms |
1528 KB |
Ok |
9 |
Correct |
19 ms |
1476 KB |
Ok |
10 |
Correct |
9 ms |
860 KB |
Ok |
11 |
Correct |
1 ms |
348 KB |
Ok |
12 |
Correct |
1 ms |
348 KB |
Ok |
13 |
Correct |
1 ms |
348 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
171 ms |
8528 KB |
Ok |
2 |
Correct |
80 ms |
4280 KB |
Ok |
3 |
Correct |
1 ms |
348 KB |
Ok |
4 |
Correct |
0 ms |
348 KB |
Ok |
5 |
Correct |
0 ms |
348 KB |
Ok |
6 |
Correct |
1 ms |
344 KB |
Ok |
7 |
Correct |
5 ms |
604 KB |
Ok |
8 |
Correct |
78 ms |
4272 KB |
Ok |
9 |
Correct |
39 ms |
2384 KB |
Ok |
10 |
Correct |
1 ms |
348 KB |
Ok |
11 |
Correct |
1 ms |
348 KB |
Ok |
12 |
Correct |
18 ms |
1496 KB |
Ok |
13 |
Correct |
0 ms |
348 KB |
Ok |
14 |
Correct |
172 ms |
8528 KB |
Ok |
15 |
Correct |
169 ms |
8516 KB |
Ok |
16 |
Correct |
178 ms |
8676 KB |
Ok |
17 |
Correct |
82 ms |
4492 KB |
Ok |
18 |
Correct |
80 ms |
4340 KB |
Ok |
19 |
Correct |
39 ms |
2388 KB |
Ok |
20 |
Correct |
39 ms |
2388 KB |
Ok |
21 |
Correct |
19 ms |
1528 KB |
Ok |
22 |
Correct |
19 ms |
1476 KB |
Ok |
23 |
Correct |
9 ms |
860 KB |
Ok |
24 |
Correct |
1 ms |
348 KB |
Ok |
25 |
Correct |
1 ms |
348 KB |
Ok |
26 |
Correct |
1 ms |
348 KB |
Ok |
27 |
Correct |
182 ms |
8524 KB |
Ok |
28 |
Correct |
86 ms |
4260 KB |
Ok |
29 |
Correct |
177 ms |
8520 KB |
Ok |
30 |
Correct |
9 ms |
860 KB |
Ok |
31 |
Correct |
1 ms |
348 KB |
Ok |
32 |
Correct |
5 ms |
604 KB |
Ok |
33 |
Correct |
20 ms |
1412 KB |
Ok |
34 |
Correct |
1 ms |
348 KB |
Ok |
35 |
Correct |
1 ms |
348 KB |
Ok |
36 |
Correct |
1 ms |
348 KB |
Ok |
37 |
Correct |
0 ms |
464 KB |
Ok |
38 |
Correct |
88 ms |
4320 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
88 ms |
4436 KB |
Ok |
2 |
Correct |
184 ms |
8528 KB |
Ok |
3 |
Correct |
183 ms |
8532 KB |
Ok |
4 |
Correct |
9 ms |
860 KB |
Ok |
5 |
Correct |
1 ms |
348 KB |
Ok |
6 |
Correct |
20 ms |
1280 KB |
Ok |
7 |
Correct |
175 ms |
8532 KB |
Ok |
8 |
Incorrect |
1 ms |
348 KB |
Output -1 while solution exists |
9 |
Halted |
0 ms |
0 KB |
- |