Submission #986378

#TimeUsernameProblemLanguageResultExecution timeMemory
986378KasymKRace (IOI11_race)C++17
0 / 100
2 ms2396 KiB
#include "bits/stdc++.h" #include "race.h" using namespace std; const int Na = 1e3 + 5; vector<pair<int, int>> adj[Na]; int mn = Na, Ka; int dfs(int x, int pr, int gal, int edge){ if(!(gal^Ka)) return edge; if(gal < 0) return Na; for(auto &i : adj[x]) if(i.first != pr) mn = min(mn, dfs(i.first, x, gal + i.second, edge + 1)); return mn; } int best_path(int n, int k, int H[][2], int L[]){ Ka = k; for(int i = 0; i < n; ++i){ int a = H[i][0], b = H[i][1]; adj[a].push_back({b, L[i]}); adj[b].push_back({a, L[i]}); } int answer = INT_MAX; for(int i = 0; i < n; ++i) answer = min(answer, dfs(i, -1, 0, 0)); return (answer >= Na ? -1 : answer); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...