// chrono::system_clock::now().time_since_epoch().count()
#include<bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " = " << x << endl;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
vi gen(int n, int k) {
if (k % 2 == 0) {
return {};
}
vi ret;
if (k == 1) {
if (n == 1) {
return vi({0, 1});
}
vi A = gen(n - 1, k);
vi B = A;
reverse(all(B));
for (int &x : B) {
x += (1 << (n - 1));
}
for (int x : A) {
ret.pb(x);
}
for (int x : B) {
ret.pb(x);
}
return ret;
}
if (n % 2 == k % 2) {
return {};
}
vi A = gen(n - 2, k - 2);
int rot = (1 << (n - 1)) + (1 << (n - 2));
int cur = 0;
for (int i : {n - 2, n - 1, n - 2, n - 1}) {
for (int x : A) {
ret.pb(cur + x);
cur ^= rot;
}
cur ^= (1 << i);
rotate(A.begin(), A.begin() + A.size() / 4, A.end());
}
return ret;
}
void solve() {
int n, k, T;
string S;
scanf("%d %d %d", &n, &k, &T);
cin >> S;
int st = 0;
for (int i = 0; i < n; ++i) {
if (S[i] == '1') {
st += (1 << i);
}
}
vi vec = gen(n, k);
if (vec.empty()) {
printf("-1\n");
return;
}
rotate(vec.begin(), find(all(vec), st), vec.end());
printf("%d\n", (1 << n));
for (int x : vec) {
for (int i = 0; i < n; ++i) {
printf("%d", (x >> i) & 1);
}
printf("\n");
}
}
int main() {
int tt = 1;
while (tt--) {
solve();
}
return 0;
}
Compilation message
lyuboyn.cpp: In function 'void solve()':
lyuboyn.cpp:73:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d %d", &n, &k, &T);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Ok |
2 |
Correct |
1 ms |
256 KB |
Ok |
3 |
Correct |
1 ms |
256 KB |
Ok |
4 |
Correct |
0 ms |
256 KB |
Ok |
5 |
Correct |
0 ms |
256 KB |
Ok |
6 |
Correct |
0 ms |
256 KB |
Ok |
7 |
Correct |
0 ms |
256 KB |
Ok |
8 |
Correct |
0 ms |
256 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
358 ms |
6552 KB |
Ok |
2 |
Correct |
179 ms |
3304 KB |
Ok |
3 |
Correct |
1 ms |
384 KB |
Ok |
4 |
Correct |
0 ms |
256 KB |
Ok |
5 |
Correct |
0 ms |
256 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Output -1 while solution exists |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
378 ms |
6504 KB |
Fail, not exactly k bits are different: line = 819 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
358 ms |
6552 KB |
Ok |
2 |
Correct |
179 ms |
3304 KB |
Ok |
3 |
Correct |
1 ms |
384 KB |
Ok |
4 |
Correct |
0 ms |
256 KB |
Ok |
5 |
Correct |
0 ms |
256 KB |
Ok |
6 |
Incorrect |
1 ms |
256 KB |
Output -1 while solution exists |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Output -1 while solution exists |
2 |
Halted |
0 ms |
0 KB |
- |