Submission #434360

#TimeUsernameProblemLanguageResultExecution timeMemory
434360ApiramRace (IOI11_race)C++14
21 / 100
3056 ms11076 KiB
//#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); } } } 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]}); } for (int i =0;i<N;++i) dfs(i,0,0,-1,K); if (ans==INT_MAX)return -1; return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...