# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
782531 | boyliguanhan | Highway Tolls (IOI18_highway) | C++17 | 0 ms | 0 KiB |
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;
vector<int> X, Y;
int N, s_state[200100];
int CALCTREE(int l, int r) {
if(l >= N) return -1;
if(r - 1 > l) {
int mid = l+r>>1;
X.push_back(0), Y.push_back(0);
int pos = X.size()-1;
Y[pos]=(CALCTREE(l, mid));
X[pos]=(CALCTREE(mid, r));
return -pos-1;
}
return 1;
}
void create_circuit(int M, vector<int> A) {
vector<int> C(M+1,-1);
A.push_back(0);
N = A.size();
int x = 1;
while(x<N)
x *= 2;
CALCTREE(0, x);
for(int &i : A) {
int cur_switch = 0;
while(cur_switch >= 0) {
s_state[cur_switch] ^= 1;
int &w = s_state[cur_switch] ? X[cur_switch] : Y[cur_switch];
if(w >= 0)
w = i, cur_switch = -1;
else
cur_switch = -1-w;
}
}
answer(C, X, Y);
}