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;
const int maxn=1e3+5;
vector<int>adj[maxn];
vector<int>ord;
int p[maxn];
void dfs(int v,int pr){
p[v]=pr;
ord.push_back(v);
for(int to:adj[v]){
if(to!=pr){
dfs(to,v);
}
}
}
void assignHints(int subtask,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,-1);
for(int i=1;i<=N;++i){
int cur=ord[i-1];
int nxt=ord[i%N];
for(int bit=0;bit<10;++bit){
setHint(cur,bit+1,nxt&(1<<bit));
setHint(cur,bit+11,p[cur]&(1<<bit));
}
}
}
void speedrun(int subtask,int N,int start){
int vis=0;
while(vis<N){
int nxt=0;
for(int bit=0;bit<10;++bit){
nxt|=(getHint(bit+1)>>bit);
}
while(!goTo(nxt)){
int pr=0;
for(int bit=0;bit<10;++bit){
pr|=(getHint(bit+11)>>bit);
}
goTo(pr);
}
}
}
# | 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... |