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 ;
void assignHints(int subtask, int N, int A[], int B[]) {
auto setFirst = [&](int x, int val){
for(int i = 0 ; i < 10 ; i++ ){
setHint(x, i+1, ((val>>i)&1) ) ;
}
return ;
} ;
auto setSecond = [&](int x, int val){
for(int i = 10 , j = 0 ; i < 20 ; i++, j++ ){
setHint(x, i+1, ((val>>j)&1) ) ;
}
return ;
} ;
setHintLen(20);
vector< vector<int> > adj(N+1, vector<int>() ) ;
vector<int> arr ;
for(int i = 1 ; i < N ; i++ ){
adj[ A[i] ].push_back( B[i] ) ;
adj[ B[i] ].push_back( A[i] ) ;
}
function<void(int,int)> dfs = [&](int x, int par ){
arr.push_back(x) ;
for(auto e : adj[x]){
if(e == par ) continue ;
setSecond(e,x) ;
dfs(e,x) ;
}
};
dfs(1,-1) ;
arr.push_back(1) ;
for(int i = 0 ; i < N ; i++ ){
setFirst(arr[i] , arr[i+1]);
}
}
void speedrun(int subtask, int N, int start) { /* your solution here */
getLength() ;
auto get = [&](int l, int r){
int tot = 0 ;
for(int i = l , j = 0 ; i <= r ; i++, j++ )
tot += (1<<j)*getHint(i) ;
return tot ;
} ;
while(start != 1){
int par = get(11,20) ;
goTo( par ) ;
start = par ;
}
int qtd = 1 ;
while( qtd < N){
int edg = get(1,10) ;
int par = get(11,20) ;
if(edg == 1) break ;
while(!goTo(edg)){
goTo(par) ;
par = get(11,20) ;
}
}
}
# | 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... |