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>
using namespace std;
#include "doll.h"
const int N = 400000;
int c[N], x[N], y[N], ext, s;
int build(int k) {
if (k <= ext) {
ext -= k;
return 1;
} else if (k == 1) {
return 0;
}
int u = ++s;
x[u - 1] = -build(k / 2);
y[u - 1] = -build(k / 2);
return u;
}
void create_circuit(int m, vector<int> a) {
int n = a.size();
int k = 1;
while (k < n) {
k *= 2;
}
ext = k - n;
int u = build(k);
fill(c + 1, c + m + 1, -u);
c[0] = a[0];
a.push_back(0);
a.erase(a.begin());
for (int i = 0; i < n; ++i) {
int v = u;
while (x[v - 1] != 0) {
swap(x[v - 1], y[v - 1]);
v = -y[v - 1];
}
swap(x[v - 1], y[v - 1]);
y[v - 1] = a[i];
}
answer(vector<int>(c, c + m + 1), vector<int>(x, x + s), vector<int>(y, y + s));
}
# | 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... |