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;
#define pb push_back
void create_circuit(int M, std::vector<int> A) {
int N = A.size();
vector<int> res(M+1,-1), x, y;
res[0] = A[0];
int logn = 1, size = 1;
while(size<N){
size*=2;
logn++;
}
int size2 = size/2;
bool womp[(int)1e6] = {0};
function<void(int,int,int,int)> push = [&](int pos,int parent, int lx, int rx) {
if(rx-lx==1) return;
if(rx<size-N) {
womp[parent] = true;
return;
}
int m = (lx+rx)/2;
push(2*pos,pos, lx,m); push(2*pos+1,pos,m,rx);
};
push(1,1,0,size);
int cnt = 0;
for(int i = 1; i<(N+1)/2; i++) {
cnt++;
if(womp[i]) {
x.pb(-1);
y.pb(-cnt-1);
continue;
}
cnt++;
x.pb(-cnt);y.pb(-cnt-1);
}
vector<int> list = {1};
while(size2>0){
int pp = list.size();
for(int i = 0; i<pp; i++) list.pb(list[i]+size2);
size2>>=1;
}
vector<int> compress;
for(int i = size-N; i<size; i++) compress.pb(list[i]);
sort(compress.begin(),compress.end());
for(int& xx : list) xx = lower_bound(compress.begin(),compress.end(),xx)-compress.begin()+1;
A.pb(0);
if(N&1)x.pb(-1);
for(int i = size-N; i<size; i++){
if(i&1) y.pb(A[list[i]]);
else x.pb(A[list[i]]);
}
answer(res,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... |