Submission #147515

#TimeUsernameProblemLanguageResultExecution timeMemory
147515Bodo171Mechanical Doll (IOI18_doll)C++14
37 / 100
133 ms10968 KiB
#include "doll.h" #include <bits/stdc++.h> using namespace std; const int nmax=400005; vector<int> C,X,Y,a,act; int et[nmax]; int p,u,ets,i,lg; int build(int nod,int l,int r) { if(l==r) return act[l]; int m=(l+r)/2; ++ets;et[nod]=ets; X[et[nod]-1]=build(2*nod,l,m); Y[et[nod]-1]=build(2*nod+1,m+1,r); return -et[nod]; } int rev(int x,int lg) { int ret=0; for(int b=0;b<lg;b++) { if((x&(1<<b))) ret|=(1<<(lg-b-1)); } return ret; } void create_circuit(int M, std::vector<int> A) { int n = A.size(); C.resize(M+1); for(i=0;i<=M;i++) C[i]=-1; while((1<<lg)<n+1) lg++; act.resize((1<<lg),0); for(i=0;i<(1<<lg);i++) act[i]=-1; for(i=0;i<A.size();i++) act[rev(i,lg)]=A[i]; act[(1<<lg)-1]=0; X.resize((1<<lg)-1);Y.resize((1<<lg)-1); build(1,0,(1<<lg)-1); answer(C, X, Y); }

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:38:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |   for(i=0;i<A.size();i++)
      |           ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...