# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
291030 | PeppaPig | "The Lyuboyn" code (IZhO19_lyuboyn) | C++14 | 617 ms | 7928 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 19;
int n, k, t, s;
mt19937 rng(time(NULL));
void print(int val) {
vector<int> vec;
for(int i = 0; i < n; i++, val >>= 1)
vec.emplace_back(val & 1);
reverse(vec.begin(), vec.end());
for(int x : vec) printf("%d", x);
printf("\n");
}
int chk[N], ans[N];
int main() {
char input[100];
scanf("%d %d %d %s", &n, &k, &t, input);
if(k % 2 == 0) return !printf("-1\n");
for(int i = 0; input[i] != '\0'; i++)
s = (s << 1) + (input[i] == '1');
vector<int> base;
for(int i = 0; i < (1 << n); i++) if(__builtin_popcount(i) == k)
base.emplace_back(i);
while(true) {
shuffle(base.begin(), base.end(), rng);
ans[0] = s;
int ptr = 1;
bool valid = true;
for(int j = 0; j < n; j++) for(int i = ptr - 1; ~i; i--) {
ans[ptr] = ans[i] ^ base[j];
if(!chk[ans[ptr]]) chk[ans[ptr]] = 1;
else {
valid = false;
break;
}
++ptr;
}
if(valid) {
printf("%d\n", (1 << n));
for(int i = 0; i < (1 << n); i++) print(ans[i]);
exit(0);
} else for(int i = 0; i < (1 << n); i++) chk[ans[i]] = 0;
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |