이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "race.h"
#include<bits/stdc++.h>
using namespace std;
struct point{
  int u,x,y,par;
};
int ans=INT_MAX;
vector<vector<pair<int,int>>>adj(2e5);
void dfs(int j,int score,int level,int par,int K){
  if (score>K)return ;
  if (score==K){
    ans=min(ans,level);
    return ;
  }
  for (auto x:adj[j]){
    if (x.first!=par){
      dfs(x.first,score+x.second,level+1,j,K);
      dfs(x.first,x.second,1,j,K);
    }
  }
}
int best_path(int N, int K, int H[][2], int L[])
{
  for (int i  =0;i<N-1;++i){
    adj[H[i][0]].push_back({H[i][1],L[i]});
    adj[H[i][1]].push_back({H[i][0],L[i]});
  }
  dfs(0,0,0,-1,K);
 
  if (ans==INT_MAX)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... |