# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1135220 | emptypringlescan | Speedrun (RMI21_speedrun) | C++17 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
#include "speedrun.h"
vector<int> adj[1005];
int par[1005];
vector<int> pre;
void dfs(int x, int p){
par[x]=p;
pre.push_back(x);
for(int i:adj[x]){
if(i==p) continue;
dfs(i,x);
}
}
void assignHints(int st, int n, int A[], int B[]){
setHintLen(20);
for(int i=1; i<n; i++){
adj[A[i]].push_back(B[i]);
adj[B[i]].push_back(A[i]);
}
dfs(1,0);
pre.push_back(pre[0]);
for(int i=1; i<=n; i++){
for(int j=0; j<10; j++){
setHint(i,j+1,1&(par[i]>>j));
}
for(int j=0; j<10; j++){
setHint(pre[i-1],j+11,1&(pre[i]>>j));
}
}
}
void speedrun(int st, int n, int start){
int cur=start,nxt=-1;
while(true){
if(nxt==-1){
nxt=0;
for(int i=0; i<10; i++){
nxt|=(getHint(i+11)<<i);
}
}
if(nxt==start) break;
if(goTo(nxt)){
cur=nxt;
nxt=-1;
}
else{
int p=0;
for(int i=0; i<10; i++){
p|=(getHint(i+1)<<i);
}
assert(goTo(p)=true);
}
}
}