Submission #783011

#TimeUsernameProblemLanguageResultExecution timeMemory
783011zsombor악어의 지하 도시 (IOI11_crocodile)C++17
100 / 100
315 ms63108 KiB
#include <iostream> #include <vector> #include <queue> #include "crocodile.h" using namespace std; vector <vector <pair <int, int>>> g(1e5); vector <int> o1(1e5, 2e9); vector <int> o2(1e5, 2e9); vector <bool> done(1e5, false); priority_queue <pair <int, int>> pq; bool update(int i, int val) { if (val < o1[i]) { o2[i] = o1[i]; o1[i] = val; return true; } if (val < o2[i]) { o2[i] = val; return true; } return false; } int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { int a, b, w; for (int i = 0; i < M; i++) { 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 < K; i++) { o1[P[i]] = o2[P[i]] = 0; pq.push({ 0,P[i] }); } while (!done[0]) { a = pq.top().second; pq.pop(); if (done[a]) continue; done[a] = true; for (auto p : g[a]) { b = p.first; w = p.second; if (update(b, o2[a] + w)) pq.push({ -o2[b], b }); } } return o2[0]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...