Submission #536965

#TimeUsernameProblemLanguageResultExecution timeMemory
536965jamezzzSpeedrun (RMI21_speedrun)C++17
100 / 100
119 ms852 KiB
#include "speedrun.h" #include <bits/stdc++.h> using namespace std; #define pf printf #define pb push_back vector<int> AL[1005],pre; int par[1005],nx[1005]; void dfs(int u,int p){ par[u]=p;pre.pb(u); for(int v:AL[u]){ if(v!=p)dfs(v,u); } } void assignHints(int subtask, int N, int A[], int B[]) { /* your solution here */ for(int i=1;i<N;++i)AL[A[i]].pb(B[i]),AL[B[i]].pb(A[i]); dfs(1,0);pre.pb(0); setHintLen(20); for(int i=1;i<=N;++i){ for(int j=1;j<=10;++j)if(par[i]&(1<<(j-1)))setHint(i,j,1); for(int j=11;j<=20;++j)if(pre[i]&(1<<(j-11)))setHint(pre[i-1],j,1); } } void speedrun(int subtask, int N, int start) { /* your solution here */ int cur=start; memset(par,-1,sizeof par); memset(nx,-1,sizeof nx); while(cur!=1){ if(par[cur]==-1){ par[cur]=0,nx[cur]=0; for(int j=1;j<=10;++j)if(getHint(j))par[cur]+=1<<(j-1); for(int j=11;j<=20;++j)if(getHint(j))nx[cur]+=1<<(j-11); } goTo(par[cur]);cur=par[cur]; } while(true){//Euler tour if(par[cur]==-1){ par[cur]=0,nx[cur]=0; for(int j=1;j<=10;++j)if(getHint(j))par[cur]+=1<<(j-1); for(int j=11;j<=20;++j)if(getHint(j))nx[cur]+=1<<(j-11); } if(nx[cur]==0)break; int to=nx[cur]; while(!goTo(to)){ goTo(par[cur]); cur=par[cur]; } cur=to; } }
#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...