#include <bits/stdc++.h>
#include "speedrun.h"
using namespace std;
#define pb push_back
const int N = 1024;
vector<int> par(N,1023),nxt(N,1023);
vector<int> adj[N];
vector<int> liste;
void dfs(int node,int p){
if (p != -1) par[node] = p;
liste.pb(node);
for (auto x : adj[node]){
if (x == p) continue;
dfs(x,node);
}
}
void assignHints(int subtask, int n, int a[], int b[]) {
for (int i = 1; i < n; i++){
adj[a[i]-1].pb(b[i]-1);
adj[b[i]-1].pb(a[i]-1);
}
dfs(0,-1);
for (int i = 0; i < n-1; i++){
nxt[liste[i]] = liste[i+1];
}
setHintLen(20);
for (int node = 0; node < n; node++){
for (int bit = 0; bit < 10; bit++){
if (nxt[node] & (1 << bit)){
setHint(node+1,bit + 1,1);
}
}
for (int bit = 0; bit < 10; bit++){
if (par[node] & (1 << bit)){
setHint(node+1,bit + 11,1);
}
}
}
}
void speedrun(int subtask, int n, int start) {
int l = getLength();
int fi = -1;
while (true){
int nxt,par;
for (int bit = 0; bit < 10; bit++){
if (getHint(bit+1)) nxt += (1 << bit);
}
for (int bit = 0; bit < 10; bit++){
if (getHint(bit+11)) par += (1 << bit);
}
if (fi == -1) fi = nxt;
else {
if (fi == nxt) return;
}
if (!goTo(nxt)){
goTo(par);
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |