Submission #1041733

#TimeUsernameProblemLanguageResultExecution timeMemory
1041733ReLiceMechanical Doll (IOI18_doll)C++17
0 / 100
30 ms10072 KiB
#include "doll.h" #include <bits/stdc++.h> #define ll int #define vll vector<ll> #define pb push_back #define sz size() using namespace std; vll x(400000,0),y(400000,0),c; vector<vll> v; ll n; void build(ll v,ll tl,ll tr){ if(tl+1>=tr){ x[v-1]=y[v-1]=1; if(tr>=n)y[v-1]=0; if(tl>=n)y[v-1]=0; //~ cout<<-v<<' '<<x[v-1]<<' '<<y[v-1]<<endl; return; }ll tm=(tl+tr)/2; x[v-1]=-v*2; y[v-1]=-v*2-1; //~ cout<<-v<<' '<<x[v-1]<<' '<<y[v-1]<<endl; build(v*2,tl,tm); build(v*2+1,tm+1,tr); } void create_circuit(int m, std::vector<int> a) { n = a.size(); ll i; c.resize(m+1,0); c[0]=a[0]; c[1]=-1; build(1,1,n); ll s=1; if(n==1)c[1]=0; vector<bool> f(400,0); for(i=0;i<10;i++){ //~ cout<<s<<' '; if(s==0)break; if(s>0){ s=c[s]; }else { if(f[-s]){ f[-s]=!f[-s]; s=y[-s-1]; }else { f[-s]=!f[-s]; s=x[-s-1]; } } } //~ cout<<endl; 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...