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) {
if (a.size() & 1)
a.emplace_back(-1);
int n = a.size(), p = 1, k = 1;
a.emplace_back(0);
vector<int> c(m + 1, -1), x(400001), y(400001), parity(400001);
while (p < n)
p *= 2;
function<int(int, int)> Build = [&](int left, int right) {
if (left == right)
return 0;
if (right < p - n)
return -1;
int m = (left + right) / 2, cur = k++;
x[cur - 1] = Build(left, m), y[cur - 1] = Build(m + 1, right);
return -cur;
};
Build(0, p - 1);
for (int i = 1; i <= n; ++i) {
int cur = -1;
while (cur) {
int& next = !parity[-cur - 1] ? x[-cur - 1] : y[-cur - 1];
parity[-cur - 1] ^= 1;
cur = next;
if (!next)
next = a[i];
}
}
c[0] = a[0];
x.resize(k), y.resize(k);
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... |