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 <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#include "doll.h"
using namespace std;
int N,M,H;
vector<int> C,X,Y,A;
int Get(int p)
{
int t=p;
p=0;
for(int i=0;i<H;i++)
p=(p<<1)|(t&1),t>>=1;
if(p<N)return A[p];
else if(p==(1<<H)-1)return 0;
return -1;
}
void create_circuit(int M, std::vector<int> A)
{
N=A.size();
::M=M;
::A=A;
C.assign(M+1,-1);
for(H=0;(1<<H)<=N;H++);
X.resize((1<<H)-1);
Y.resize((1<<H)-1);
for(int i=1;i<(1<<H);i++)
{
if(i*2<(1<<H))
{
X[i-1]=-(i*2);
Y[i-1]=-(i*2+1);
}
else
{
X[i-1]=Get(i*2-(1<<H));
Y[i-1]=Get(i*2+1-(1<<H));
}
}
//for(int i=0;i<C.size();i++)cout<<C[i]<<' ';cout<<endl;
//for(int i=0;i<X.size();i++)cout<<X[i]<<' '<<Y[i]<<endl;
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... |