Submission #587673

#TimeUsernameProblemLanguageResultExecution timeMemory
587673alirezasamimi100Mechanical Doll (IOI18_doll)C++17
10 / 100
1 ms212 KiB
#include "doll.h" #include <bits/stdc++.h> using namespace std; #define pb push_back vector<int> X,Y,A; int N; int solve(int k, int j){ int v=-(int)X.size()-1; if((1<<j)==N){ if(A[k]==-1){ X.pb(v); Y.pb(-1); return v; } return A[k]; } X.pb(0); Y.pb(0); int x=solve(k,j+1),y=solve(k+(1<<j),j+1); X[-v-1]=x; Y[-v-1]=y; return v; } void create_circuit(int M, vector<int> wtf) { A=wtf; vector<int> C(M + 1, -1); if((int)A.size()==1){ C[0]=A[0]; C[A[0]]=0; answer(C,X,Y); return; } A.pb(0); C[0]=A[0]; A.erase(A.begin()); N = A.size(); int x=1; while(x<N) x*=2; reverse(A.begin(),A.end()); while((int)A.size()<x) A.pb(-1); reverse(A.begin(),A.end()); N=x; solve(0,0); answer(C, X, Y); }
#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...