#include <bits/stdc++.h>
using namespace std;
#define flipbit(x, i) x ^= (1<<(i))
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;
}
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));
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);
}
}
for (int x : ans){
if (cnt[x]){
cout << -1;
return 0;
}
cnt[x]++;
}
cout << (1<<N) << '\n';
for (int x : ans){
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 |
Correct |
1 ms |
348 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Ok |
2 |
Correct |
23 ms |
3588 KB |
Ok |
3 |
Correct |
8 ms |
2144 KB |
Ok |
4 |
Correct |
1 ms |
348 KB |
Ok |
5 |
Correct |
1 ms |
712 KB |
Ok |
6 |
Correct |
1 ms |
348 KB |
Ok |
7 |
Correct |
1 ms |
348 KB |
Ok |
8 |
Correct |
10 ms |
2144 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
168 ms |
8608 KB |
Ok |
2 |
Correct |
79 ms |
4344 KB |
Ok |
3 |
Correct |
1 ms |
348 KB |
Ok |
4 |
Correct |
1 ms |
348 KB |
Ok |
5 |
Correct |
1 ms |
348 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Ok |
2 |
Correct |
4 ms |
604 KB |
Ok |
3 |
Correct |
79 ms |
4484 KB |
Ok |
4 |
Correct |
39 ms |
2372 KB |
Ok |
5 |
Incorrect |
1 ms |
348 KB |
Output -1 while solution exists |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
179 ms |
8528 KB |
Ok |
2 |
Correct |
176 ms |
8668 KB |
Ok |
3 |
Incorrect |
8 ms |
3676 KB |
Output -1 while solution exists |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
168 ms |
8608 KB |
Ok |
2 |
Correct |
79 ms |
4344 KB |
Ok |
3 |
Correct |
1 ms |
348 KB |
Ok |
4 |
Correct |
1 ms |
348 KB |
Ok |
5 |
Correct |
1 ms |
348 KB |
Ok |
6 |
Correct |
1 ms |
600 KB |
Ok |
7 |
Correct |
4 ms |
604 KB |
Ok |
8 |
Correct |
79 ms |
4484 KB |
Ok |
9 |
Correct |
39 ms |
2372 KB |
Ok |
10 |
Incorrect |
1 ms |
348 KB |
Output -1 while solution exists |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
83 ms |
4492 KB |
Ok |
2 |
Correct |
187 ms |
8508 KB |
Ok |
3 |
Correct |
175 ms |
8776 KB |
Ok |
4 |
Correct |
9 ms |
860 KB |
Ok |
5 |
Correct |
1 ms |
348 KB |
Ok |
6 |
Correct |
20 ms |
1372 KB |
Ok |
7 |
Correct |
166 ms |
8528 KB |
Ok |
8 |
Incorrect |
1 ms |
348 KB |
Output -1 while solution exists |
9 |
Halted |
0 ms |
0 KB |
- |