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>
#include "doll.h"
using namespace std;
void create_circuit(int M, vector <int> a) {
int N = a.size(), offset = 1;
while (offset <= N)
offset *= 2;
int curr = 1, cnt = 0;
vector <int> state(offset);
vector <int> pos(offset);
while (cnt < offset)
if (curr < offset) {
int nxt = 2 * curr + state[curr];
state[curr] ^= 1;
curr = nxt;
}
else {
pos[curr - offset] = cnt++;
curr = 1;
}
vector <int> x(offset - 1), y(offset - 1);
for (int i = 1; i < offset; i++) {
auto get_next = [&](int node) {
if (node < offset)
return -node;
node = pos[node - offset];
if (node < N)
return a[node];
return node == offset - 1 ? 0 : -1;
};
x[i - 1] = get_next(2 * i);
y[i - 1] = get_next(2 * i + 1);
}
answer(vector <int> (M + 1, -1), x, y);
}
# | 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... |