제출 #582710

#제출 시각아이디문제언어결과실행 시간메모리
582710stevancv악어의 지하 도시 (IOI11_crocodile)C++14
100 / 100
512 ms64496 KiB
#include <bits/stdc++.h> #include "crocodile.h" #define ll long long #define ld long double #define sp ' ' #define en '\n' #define smin(a, b) a = min(a, b) #define smax(a, b) a = max(a, b) using namespace std; int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]) { vector<vector<pair<int, int>>> g(n); 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]}); } vector<int> was(n); vector<ll> da(n, 1e18), db(n, 1e18); priority_queue<pair<ll, pair<int, int>>> pq; for (int i = 0; i < k; i++) { was[p[i]] = 1; da[p[i]] = db[p[i]] = 0; pq.push({0, {p[i], -1}}); } while (!pq.empty()) { auto xyz = pq.top(); pq.pop(); ll x = -xyz.first; int y = xyz.second.first; int z = xyz.second.second; was[y]++; if (was[y] != 2) continue; for (auto u : g[y]) { if (u.first == z) continue; ll di = x + u.second; if (da[u.first] > di) { db[u.first] = da[u.first]; da[u.first] = di; pq.push({-di, {u.first, y}}); } else if (db[u.first] > di) { db[u.first] = di; pq.push({-di, {u.first, y}}); } } } return db[0]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...