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>
#define eb emplace_back
using namespace std;
const int MAXN = 200055;
int B[MAXN*2][2], C[MAXN*2];
int A[MAXN];
int N, M, K, NP;
int f(int s, int e) {
if(N <= s) return 1;
if(s == e) return -1;
int m = (s+e) >> 1, c = ++K;
B[c][1] = f(s, m);
B[c][0] = f(m+1, e);
return c;
}
void solve() {
N++; for(NP = 2; NP < N; NP <<= 1);
f(0, NP-1);
for(int i = 1, c = 0; c < N;) {
int &j = B[i][C[i]&1]; C[i]++;
if(j < 0) {
j = -A[c++];
i = 1;
continue;
}
i = j;
}
vector<int> CV(M+1, -1), LV, RV;
for(int i = 1; i <= K; i++) {
LV.eb(-B[i][0]);
RV.eb(-B[i][1]);
}
answer(CV, LV, RV);
}
void create_circuit(int M, std::vector<int> A) {
::M = M; ::N = A.size();
for(int i = 0; i < ::N; i++) ::A[i] = A[i];
solve();
}
# | 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... |