이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include"race.h"
#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int>>g[200005];
int k,i,inf=2e9,ans=inf;
void dfs(int v,int p,int depth,int val){
if(val==k)ans=min(ans,depth);
if(val>=k)return;
for(auto to:g[v])if(to.first!=p)dfs(to.first,v,depth+1,val+to.second);
}
int best_path(int n,int K,int h[][2],int l[]){
k=K;
for(i=0;i<k;i++){
g[h[i][1]].push_back({h[i][0],l[i]});
g[h[i][0]].push_back({h[i][1],l[i]});
}
for(i=0;i<n;i++)dfs(i,i,1,0);
if(ans==inf)return -1;
return ans;
}
# | 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... |