제출 #758079

#제출 시각아이디문제언어결과실행 시간메모리
758079Blagoj악어의 지하 도시 (IOI11_crocodile)C++14
100 / 100
483 ms72220 KiB
#include "crocodile.h" #include <bits/stdc++.h> using namespace std; #define endl '\n' #define ll long long #define all(x) x.begin(), x.end() int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { int n = N, m = M, k = K; vector<pair<int, int>> g[n + 2]; 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]}); } int vis[n + 2]; memset(vis, 0, sizeof(vis)); priority_queue<pair<ll, int>> pq; for (int i = 0; i < k; i++) { vis[P[i]] = 1; pq.push({0, P[i]}); } ll ans = 0; while (pq.size() > 0) { auto x = pq.top(); pq.pop(); x.first *= -1; if (vis[x.second] == 0) { vis[x.second] = 1; continue; } if (vis[x.second] == 2) continue; if (x.second == 0) { ans = x.first; break; } vis[x.second] = 2; for (auto y : g[x.second]) { if (vis[y.first] == 2) continue; pq.push({-(x.first + y.second), y.first}); } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...