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 "race.h"
#include <bits/stdc++.h>
using namespace std;
int dfsv[200005];
int ans=INT_MAX;
int vern;
vector < pair < int , int > > e[200005];
void dfs(int vernow,int roa,int len,int tarlen){
dfsv[vernow]=1;
if(len==tarlen){ans=min(ans,roa);return;}
if(len>tarlen)return;
for(int i=0;i<e[vernow].size();i++){
if(dfsv[e[vernow][i].first]==0){
dfs(e[vernow][i].first,roa+1,len+e[vernow][i].second,tarlen);
}
}
return;
}
int best_path(int N, int K, int H[][2], int L[])
{
vern=N;
for(int i=0;i<N-1;i++){
e[H[i][0]].push_back(make_pair(H[i][1],L[i]));
e[H[i][1]].push_back(make_pair(H[i][0],L[i]));
}
for(int i=0;i<N;i++){
memset(dfsv,0,sizeof(dfsv));
dfs(i,0,0,K);
}
return ans==INT_MAX ? -1 : ans ;
}
Compilation message (stderr)
race.cpp: In function 'void dfs(int, int, int, int)':
race.cpp:12:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<e[vernow].size();i++){
~^~~~~~~~~~~~~~~~~
# | 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... |