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;
vector<int> seq, X, Y, C;
int sz, dpth, layer;
void dfs(int u, int d, int v){
if(d < dpth){
dfs(u * 2, d + 1, v);
dfs(u * 2 + 1, d + 1, v + (1 << (d - 1)));
X[u - 1] = -u * 2; Y[u - 1] = X[u - 1] - 1;
}else{
X[u - 1] = (v >= sz - 1 ? -1 : seq[v]);
if(v + (1 << (d - 1)) == (1 << dpth) - 1) Y[u - 1] = 0;
else Y[u - 1] = (v + (1 << (d - 1)) >= sz - 1 ? -1 : seq[v + (1 << (d - 1))]);
}
}
void create_circuit(int M, vector<int> A){
seq.clear(), X.clear(), Y.clear(), C.clear();
seq = A;
sz = seq.size() + 1;
dpth = log2(sz);
if((1 << dpth) != sz) dpth++;
layer = (1 << dpth) - 1;
X.resize(layer), Y.resize(layer), C.resize(M + 1);
dfs(1, 1, 0);
for(int i = 0; i <= M; i++) C[i] = -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... |