Submission #1022711

#TimeUsernameProblemLanguageResultExecution timeMemory
1022711socpiteCrocodile's Underground City (IOI11_crocodile)C++14
100 / 100
572 ms67728 KiB
#include "crocodile.h" #include<bits/stdc++.h> using namespace std; const int maxn = 1e5+5; const int INF = 1e9+5; vector<pair<int, int>> g[maxn]; int d[maxn][2]; int vis[maxn]; int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { for(int i = 0; i < N; i++){ g[i].clear(); d[i][0] = d[i][1] = INF; vis[i] = 0; } for(int i = 0; i < M; i++){ g[R[i][0]].push_back({R[i][1], L[i]}); g[R[i][1]].push_back({R[i][0], L[i]}); } priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq; for(int i = 0; i < K; i++){ d[P[i]][0] = d[P[i]][1] = 0; pq.push({0, P[i]}); } while(!pq.empty()){ auto x = pq.top(); pq.pop(); if(vis[x.second])continue; vis[x.second] = 1; for(auto v: g[x.second]){ int tmp = x.first + v.second; if(tmp < d[v.first][0]){ d[v.first][1] = d[v.first][0]; d[v.first][0] = tmp; } else d[v.first][1] = min(tmp, d[v.first][1]); pq.push({d[v.first][1], v.first}); } } return d[0][1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...