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 "doll.h"
#include <string.h>
using namespace std;
typedef vector<int> vi;
const int N = 200000, N_ = 1 << 18; /* N_ = pow2(ceil(log2(N))) */
int tmp[N_];
void split(int *aa, int n) {
int i, j, k;
for (i = 0, j = n / 2, k = 0; k < n; k++)
tmp[k % 2 == 0 ? i++ : j++] = aa[k];
memcpy(aa, tmp, n * sizeof *tmp);
}
vi xx, yy;
void build(int *aa, int n, int idx) {
if (n == 2)
xx[idx] = aa[0], yy[idx] = aa[1];
else {
split(aa, n);
xx[idx] = -(idx * 2 + 1 + 1), yy[idx] = -(idx * 2 + 2 + 1);
build(aa, n / 2, idx * 2 + 1), build(aa + n / 2, n / 2, idx * 2 + 2);
}
}
int aa[N_];
void create_circuit(int m, vi aa_) {
vi cc(m + 1);
int n = aa_.size(), n_, i;
n_ = 1;
while (n_ < n + 1)
n_ <<= 1;
for (i = 0; i < n_ - (n + 1); i++)
aa[i] = -1;
for (i = 0; i < n; i++)
aa[n_ - (n + 1) + i] = aa_[i];
xx.resize(n_ - 1), yy.resize(n_ - 1);
build(aa, n_, 0);
for (i = 0; i <= m; i++)
cc[i] = -1;
answer(cc, xx, yy);
}
# | 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... |