Submission #1052795

#TimeUsernameProblemLanguageResultExecution timeMemory
1052795woodMechanical Doll (IOI18_doll)C++17
10 / 100
1 ms1624 KiB
#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; } 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<size2; 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 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...