이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "doll.h"
using namespace std;
void create_circuit(int m, vector<int> a) {
int n = (int) a.size();
vector<int> c(m + 1, 0), x, y;
c[0] = a[0];
a.push_back(0);
a.erase(a.begin());
auto create = [&]() {
x.push_back(0), y.push_back(0);
return (int) x.size();
};
create();
fill(c.begin() + 1, c.end(), -1);
constexpr int inf = 228228228;
function<void(int, int, int)> solve = [&](int v, int sz, int real) -> void {
if (sz == 2) {
y[v - 1] = inf;
real -= 1;
} else {
int R = min(sz >> 1, real);
int nxt = create();
y[v - 1] = -nxt;
solve(nxt, sz >> 1, R);
real -= R;
}
if (real <= 0) {
x[v - 1] = -1;
} else {
if (sz == 2) {
x[v - 1] = inf;
} else {
int nxt = create();
x[v - 1] = -nxt;
solve(nxt, sz >> 1, real);
}
}
};
int sz = 2;
while (sz < n) sz <<= 1;
solve(1, sz, n);
int cur = c[0], pnt = 0;
vector<int> tp((int) x.size());
while (cur != 0) {
if (cur > 0) {
cur = c[cur];
continue;
} else {
cur = -cur;
tp[cur - 1] ^= 1;
if (tp[cur - 1] == 1) {
if (x[cur - 1] == inf) {
x[cur - 1] = a[pnt++];
}
cur = x[cur - 1];
} else {
if (y[cur - 1] == inf) {
y[cur - 1] = a[pnt++];
}
cur = y[cur - 1];
}
}
}
answer(c, 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... |