이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |