#include <bits/stdc++.h>
#include "doll.h"
using namespace std;
const int maxn=2e5;
int ls,k,li;
vector<int> c,x(2*maxn),y(2*maxn);
vector<pair<int,int*>> st;
vector<int*> lp;
int build(int n,int d,int idx){
if(!n)return -1e9;
else if(!d)return 1e9;
else{
int s=1<<d-1,c=max(0,n-s);
int id1=build(c,d-1,idx),id2=build(n-c,d-1,idx|1<<k-d);
int t=li++;
x[t]=id1;
y[t]=id2;
if(id1==1e9)st.push_back({idx,&x[t]});
else if(id1==-1e9)lp.push_back(&x[t]);
if(id2==1e9)st.push_back({idx|1<<k-d,&y[t]});
else if(id2==-1e9)lp.push_back(&y[t]);
return --ls;
}
}
void create_circuit(int m, std::vector<int> a) {
vector<int> out[m+1];
a.push_back(0);
int n=a.size();
while((1<<k)<n)k++;
int id=build(n,k,0);
c.resize(m+1);
for(int i=0;i<=m;i++)c[i]=id;
for(auto it:lp)*it=id;
sort(st.begin(),st.end());
int idx=0;
for(auto[v,it]:st)*it=a[idx++];
while(x.size()>li)x.pop_back();
while(y.size()>li)y.pop_back();
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... |