Submission #561069

#TimeUsernameProblemLanguageResultExecution timeMemory
561069promaRace (IOI11_race)C++17
0 / 100
1 ms340 KiB
#include "race.h" #include <bits/stdc++.h> using namespace std; vector <pair <int, int>> g[1005]; int ans, k; void dfs(int v, int p = -1, int dep = 0, int len = 0) { if (len == k) ans = min(ans, dep); for (auto i: g[v]) { if (i.first != p) dfs(i.first, v, dep + 1, len + i.second); } } int best_path(int N, int K, int H[][2], int L[]) { k = K; for (int i = 0; i < N; i ++) { g[H[i][0]].push_back({H[i][1], L[i]}); g[H[i][1]].push_back({H[i][0], L[i]}); } ans = 1e9; for (int i = 0; i < N; i ++) { dfs(i); } if (ans == 1e9) ans = -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...