Submission #1090112

#TimeUsernameProblemLanguageResultExecution timeMemory
1090112LilPlutonRace (IOI11_race)C++14
0 / 100
3059 ms8284 KiB
#include "race.h" #include <bits/stdc++.h> using namespace std; const int sz = 2e5 + 5; vector<vector<pair<int,int>>>adj(sz); int n, res; vector<long long> dist(sz), dep(sz, 0); void dij(int s,int need){ dist.assign(sz, INT_MAX); dep.assign(sz, INT_MAX); priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>>q; dep[s] = 0; q.push({0, s}); while(!q.empty()){ int v = q.top().second; int d_v = q.top().first; if(d_v != dist[v]){ continue; } if(dist[v] == need){ res = min(1LL * res, dep[v]); return; } for(auto i : adj[v]){ if(dist[i.first] > dist[v] + i.second){ dep[i.first] = dep[v] + 1; dist[i.first] = dist[v] + i.second; q.push({dist[i.first], i.first}); } } } } int best_path(int N, int K, int H[][2], int L[]) { if(K == 1){ return 0; } n = N; for(int i = 0; i < n; ++i){ adj[H[i][0]].push_back({H[i][1], L[i]}); adj[H[i][1]].push_back({H[i][0], L[i]}); } res = INT_MAX; for(int i = 0; i < n; ++i){ dij(i, K); } return (res == INT_MAX ? -1 : res); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...