This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "speedrun.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
void dfs(int x,int p){
//cout<<x<<' '<<p<<endl;
int to=0;
for (int i=1;i<=10;i++) if (getHint(i)) to+=(1<<(i-1));
if (to && to!=p) goTo(to),dfs(to,x);
to=0;
for (int i=11;i<=20;i++) if (getHint(i)) to+=(1<<(i-11));
if (to && to!=p) goTo(to),dfs(to,x);
if (p) goTo(p);
return;
}
void assignHints(int subtask, int n, int A[], int B[]) {
setHintLen(20);
vector<int> adj[n+2];
for (int i=1;i<n;i++) adj[A[i]].pb(B[i]),adj[B[i]].pb(A[i]);
for (int i=1;i<=n;i++){
int x=adj[i][0],y=0;
if (adj[i].size()==2) y=adj[i][1];
for (int j=0;j<10;j++) if (x&(1<<j)) setHint(i,j+1,1);
for (int j=0;j<10;j++) if (y&(1<<j)) setHint(i,j+11,1);
}return;
}
void speedrun(int subtask, int n, int start) {
dfs(start,0);
return;
}
# | 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... |