제출 #974456

#제출 시각아이디문제언어결과실행 시간메모리
974456saayan007경주 (Race) (IOI11_race)C++17
21 / 100
26 ms9288 KiB
#include "race.h" #include "bits/stdc++.h" using namespace std; #define rep(i, a, b) for(int i = (a); i <= (b); ++i) #define repd(i, a, b) for(int i = (a); i >= (b); --i) #define em emplace #define eb emplace_back const int M = 1010; vector<pair<int, int>> adj[M]; int dfs(int x, int p, int rem, int len) { if(rem == 0) return len; if(rem < 0) return M; int ans = M; for(auto [y, w] : adj[x]) { if(y == p) continue; ans = min(ans, dfs(y, x, rem - w, len + 1)); } return ans; } int best_path(int N, int K, int H[][2], int L[]) { rep(i, 0, N - 2) { adj[H[i][0] + 1].eb(H[i][1] + 1, L[i]); adj[H[i][1] + 1].eb(H[i][0] + 1, L[i]); } int ans = N; rep(i, 1, N) { ans = min(ans, dfs(i, 0, K, 0)); } return (ans >= N ? -1 : 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...