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"
vector<int> s, x(1<<18), y(1<<18), z(1<<18);
int cnt, v = -1, rt = -1, b, n;
int dfs(int l, int r) {
if(l >= n) return -1;
if(r - l < 2) {
return 1;
} else {
int m = (l + r) / 2;
int u = cnt++;
y[u] = dfs(l, m);
x[u] = dfs(m, r);
return -u-1;
}
}
void create_circuit(int M, vector<int> A) {
s.assign(M+1, -1);
A.push_back(0);
cnt = b = 0, v = -1, rt = -1, n = size(A);
x.assign(2*n, 0);
y.assign(2*n, 0);
z.assign(2*n, 0);
while((1<<b)<n) ++b;
dfs(0, 1<<b);
for(int &i : A) {
int u = 0;
while(u >= 0) {
z[u] ^= 1;
int w = -1-(z[u] ? x[u] : y[u]);
if(w < 0) {
(z[u] ? x[u] : y[u]) = i;
rt = u; u = -1;
} else u = w;
}
}
if(n > 2) {
x[cnt] = -1-cnt;
y[rt] = -1-cnt++;
}
x.resize(cnt);
y.resize(cnt);
answer(s, 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... |