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 <bits/stdc++.h>
using namespace std;
int N;
vector<int> S, C, X, Y;
void go(int id, int c, int ord) {
if(c >= N+1) {
X[-id-1] = S[ord];
if(c/2+ord == c-1) Y[-id-1] = 0;
else if(c/2+ord >= N) Y[-id-1] = -1;
else Y[-id-1] = S[c/2 + ord];
return;
}
X[-id-1] = id*2;
Y[-id-1] = id*2-1;
go(id*2, c*2, ord);
go(id*2-1, c*2, ord+c/2);
}
void create_circuit(int M, vector<int> A) {
N = A.size(); S = A;
C.resize(M + 1);
if(N == 1) {
C[0] = 1; C[1] = 0;
answer(C, X, Y);
return;
}
C[0] = -1;
for(int i=1; i<=M; i++) C[i] = -1;
int i;
for(i=1; (1<<i)<N+1; i++);
X.resize((1<<i) - 1);
Y.resize((1<<i) - 1);
go(-1, 2, 0);
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... |