제출 #821825

#제출 시각아이디문제언어결과실행 시간메모리
821825nemethm경주 (Race) (IOI11_race)C++17
21 / 100
3047 ms11784 KiB
#include "race.h" #include <bits/stdc++.h> using namespace std; using ll = long long int; vector<pair<int,ll>> g[100100]; ll level[100100], dist[100100]; ll k, ans = -1; void dfs(int node, int prev = -1){ if(dist[node] == k){ ans = ans == -1 ? level[node] : min(ans, level[node]); } for(auto i : g[node]){ if(i.first != prev){ level[i.first] = level[node] + 1; dist[i.first] = dist[node] + i.second; dfs(i.first, node); } } } int best_path(int N, int K, int H[][2], int L[]) { k = K; for(int i = 0; i < N - 1; ++i){ g[H[i][0]].push_back({H[i][1], L[i]}); g[H[i][1]].push_back({H[i][0], L[i]}); } for(int i = 0; i < N; ++i){ fill(level, level + N, 0); fill(dist, dist + N, 0); dfs(i); } 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...