제출 #587722

#제출 시각아이디문제언어결과실행 시간메모리
587722alirezasamimi100자동 인형 (IOI18_doll)C++17
68.82 / 100
78 ms10680 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(A[(((N-1)>>j)<<j)+k]==-1){ X.pb(v); Y.pb(-1); return v; } if((1<<j)==N){ 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) { vector<int> C(M + 1, -1); if((int)wtf.size()==1){ C[0]=wtf[0]; C[wtf[0]]=0; answer(C,X,Y); return; } wtf.pb(0); C[0]=wtf[0]; wtf.erase(wtf.begin()); N = wtf.size(); int x=1,p=0; while(x<N) x*=2,p++; vector<int> vec; for(int i=0; i<p; i++){ if((x-N)>>i&1) vec.pb(i); } reverse(vec.begin(),vec.end()); A.resize(x,0); int k=0,t=0; for(int i : vec){ for(int j=0; j<(1<<i); j++){ A[(j<<(p-i))|k]=-1; } k|=1<<(p-i-1); } N=x; for(int i=0; i<N; i++){ if(A[i]==-1) continue; A[i]=wtf[t++]; } 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...