Submission #986376

#TimeUsernameProblemLanguageResultExecution timeMemory
986376KasymKRace (IOI11_race)C++17
0 / 100
162 ms262144 KiB
#include "bits/stdc++.h" using namespace std; const int N = 1e3 + 5; vector<pair<int, int>> adj[N]; int mn = N, K; int dfs(int x, int pr, int gal, int edge){ if(!(gal^K)) return edge; if(gal < 0) return N; for(auto &i : adj[x]) if(i.first != x) 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[]){ K = 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 >= N ? -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...