Submission #538707

#TimeUsernameProblemLanguageResultExecution timeMemory
538707JasiekstrzSpeedrun (RMI21_speedrun)C++17
100 / 100
197 ms844 KiB
#include<bits/stdc++.h> #include "speedrun.h" using namespace std; const int NN=1e3; const int L=20; vector<int> e[NN+10]; vector<int> pre,par; void encode(int x,int c1,int c2) { int c=(c1<<10)+c2; for(int i=1;i<=20;i++) { setHint(x,i,c%2); c/=2; } return; } void dfs(int x,int p) { pre.push_back(x); par.push_back(p); for(auto v:e[x]) { if(v!=p) dfs(v,x); } return; } void assignHints(int subtask, int N, int A[], int B[]) { setHintLen(L); for(int i=1;i<N;i++) { e[A[i]].push_back(B[i]); e[B[i]].push_back(A[i]); } dfs(1,0); pre.push_back(pre[0]); for(int i=0;i<N;i++) encode(pre[i],pre[i+1],par[i]); return; } pair<int,int> decode(int x) { int ans=0; for(int i=20;i>=1;i--) ans=2*ans+getHint(i); return {(ans>>10),ans%(1<<10)}; } void speedrun(int subtask, int N, int start) { int x=start; while(x!=1) { x=decode(x).second; goTo(x); } for(int i=1;i<=N;i++) { int y=decode(x).first; while(!goTo(y)) { x=decode(x).second; goTo(x); } } return; }
#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...