# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
636805 | valerikk | "The Lyuboyn" code (IZhO19_lyuboyn) | C++17 | 36 ms | 6288 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 <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int N, K, T;
int f[1 << 19];
int read() {
static char buf[19];
scanf("%s", buf);
int res = 0;
for(int i = 0; i < N; ++i) {
res |= (buf[i] - '0') << i;
}
return res;
}
void write(int x) {
static char buf[19];
for(int i = 0; i < N; ++i) {
buf[i] = '0' + ((x >> i) & 1);
}
buf[N] = '\0';
printf("%s\n", buf);
}
int main() {
scanf("%d%d%d", &N, &K, &T);
int S = read();
if(!(K & 1)) {
printf("-1\n");
return 0;
}
f[0] = 0;
f[1] = 1;
for(int p = 1; p <= K; ++p) {
for(int i = 0; i < (1 << p); ++i) {
f[(1 << p) + i] = f[(1 << p) - i - 1] ^ (1 << p);
}
}
for(int i = 0; i < (1 << (K + 1)); i += 2) {
f[i] ^= (1 << (K + 1)) - 1;
}
for(int p = K + 1; p < N; ++p) {
for(int i = 0; i < (1 << p); ++i) {
f[(1 << p) + i] = f[(1 << p) - i - 1] ^ (1 << p) ^ ((1 << (K - 1)) - 1);
}
}
int start = 0;
while(f[start] != S) {
++start;
}
rotate(f, f + start, f + (1 << N));
for(int i = 0; i < (1 << N); ++i) {
write(f[i]);
}
}
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... |