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"
//#define int long long
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
using namespace std;
vector<int> x,y,state,hm;
int p=1,p2=0;
void give_index(int rt,int l,int r){
int mid = (l+r)/2;
if(mid+1>=sz(hm)) x[rt]=-1;
else{
x[rt]=-(++p);
x.push_back(0);
y.push_back(0);
state.push_back(0);
if(l!=r) give_index(-x[rt],mid+1,r);
}
y[rt]=-(++p);
x.push_back(0);
y.push_back(0);
state.push_back(0);
if(l!=r) give_index(-y[rt],l,mid);
}
void make_leaf(int rt){
if(state[rt]==0){
state[rt]^=1;
if(x[rt]==0) x[rt]=hm[p2++];
else make_leaf(-x[rt]);
}
else{
state[rt]^=1;
if(y[rt]==0) y[rt]=hm[p2++];
else make_leaf(-y[rt]);
}
}
void create_circuit(int m, vector<int> a){
int n = sz(a);
vector<int> c(m+1);
x.push_back(0);
y.push_back(0);
state.push_back(0);
a.push_back(0);
x.push_back(0);
y.push_back(0);
state.push_back(0);
hm=a;
for(int i=0;i<=m;i++) c[i]=-1;
int nd=1;
while(nd*2<sz(hm)) nd<<=1;
give_index(1,1,nd);
make_leaf(1);
reverse(all(x));
x.pop_back();
reverse(all(x));
reverse(all(y));
y.pop_back();
reverse(all(y));
answer(c, x, y);
}
Compilation message (stderr)
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:43:7: warning: unused variable 'n' [-Wunused-variable]
43 | int n = sz(a);
| ^
# | 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... |