제출 #1019392

#제출 시각아이디문제언어결과실행 시간메모리
1019392stdfloat악어의 지하 도시 (IOI11_crocodile)C++17
89 / 100
391 ms68544 KiB
#include <bits/stdc++.h> #include "crocodile.h" using namespace std; #define ff first #define ss second #define pii pair<int, int> using ll = long long; int travel_plan(int n, int M, int R[][2], int L[], int K, int P[]) { vector<vector<pii>> E(n); for (int i = 0; i < M; i++) { E[R[i][0]].push_back({R[i][1], L[i]}); E[R[i][1]].push_back({R[i][0], L[i]}); } vector<int> vis(n, -1); vector<pair<ll, ll>> dis(n, {LLONG_MAX, LLONG_MAX}); priority_queue<pair<ll, pii>> q; for (int i = 0; i < K; i++) { vis[P[i]] = -2; dis[P[i]] = {0, 0}; q.push({0, {P[i], -1}}); } while (!q.empty()) { ll d = -q.top().ff; auto [x, p] = q.top().ss; q.pop(); if (d != dis[x].ff) continue; if (vis[x] == -1 || vis[x] == p) { vis[x] = p; dis[x] = {dis[x].ss, LLONG_MAX}; continue; } for (auto [i, w] : E[x]) { if (d + w < dis[i].ss && vis[i] != x) { dis[i].ss = d + w; if (dis[i].ff > dis[i].ss) swap(dis[i].ff, dis[i].ss); q.push({-d - w, {i, x}}); } } } return dis[0].ff; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...