제출 #1092595

#제출 시각아이디문제언어결과실행 시간메모리
1092595PagodePaivaCrocodile's Underground City (IOI11_crocodile)C++17
100 / 100
310 ms61660 KiB
#include<bits/stdc++.h> #include "crocodile.h" #define inf 1e9 + 10 using namespace std; const int N = 100010; vector <pair <int, int>> g[N]; int dist1[N], dist2[N], pai[N]; int travel_plan(int n, int m, int R[][2], int L[], int k, int P[]){ for(int i = 0;i < m;i++){ int a = R[i][0], b = R[i][1], w = L[i]; g[a].push_back({b, w}); g[b].push_back({a, w}); } for(int i = 0;i <= n;i++) dist1[i] = dist2[i] = inf; priority_queue <pair <int, int>> pq; for(int i = 0;i < k;i++){ dist1[P[i]] = dist2[P[i]] = 0; pq.push({0, P[i]}); } while(!pq.empty()){ auto [d, v] = pq.top(); pq.pop(); d *= -1; if(d != dist2[v]) continue; for(auto [x, w] : g[v]){ if(dist1[x] > dist2[v] + w){ if(pai[x] != v) { dist2[x] = dist1[x]; if(dist2[x] != inf) pq.push({-dist2[x], x}); } dist1[x] = dist2[v] + w; pai[x] = v; } else if(dist2[x] > dist2[v] + w and pai[x] != v){ dist2[x] = dist2[v] + w; pq.push({-dist2[x], x}); } } } return dist2[0]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...