Submission #926815

#TimeUsernameProblemLanguageResultExecution timeMemory
926815tombCrocodile's Underground City (IOI11_crocodile)C++17
0 / 100
1 ms4444 KiB
#include<bits/stdc++.h> using namespace std; #define vi vector<int> #define vb vector<bool> #define vvb vector<vb> #define pli pair<ll, int> #define pil pair<int, ll> #define pii pair<int, int> #define pll pair<ll, ll> #define vpii vector<pii> #define vpli vector<pli> #define vpil vector<pil> #define vpll vector<pll> #define ll long long #define vll vector<ll> #define vvll vector<vll> #define f first #define s second #define pb push_back #define MAXN (int) 1e5 ll travel_plan(int n, int m, int R[][2], int *L, int k, int *P){ vector<vpll> adj(n); for (int i = 0; i < m; i++) adj[R[i][0]].pb({R[i][1], L[i]}), adj[R[i][1]].pb({R[i][0], L[i]}); priority_queue<pli, vpli, greater<pli>> pq; pq.push({0, 0}); vll dist(n, 2e18), dist2(n, 2e18), par(n, -1); vb vis(n); dist[0] = dist2[0] = 0; while (pq.size()){ int u; ll w; tie (w, u) = pq.top(); if (vis[u]) continue; vis[u] = true; pq.pop(); for (auto [v, cost] : adj[u]){ if (dist[v] > dist[u] + cost) pq.push({dist[v] = dist[u] + cost, v}), par[v] = u; } } vis.assign(n, 0); while (pq.size()){ int u; ll w; tie (w, u) = pq.top(); if (vis[u]) continue; vis[u] = true; pq.pop(); for (auto [v, cost] : adj[u]){ if (dist2[v] > dist2[u] + cost && par[v] != u) pq.push({dist2[v] = dist2[u] + cost, v}); } } ll min_cost = LLONG_MAX; for (int i = 0; i < k; i++) min_cost = min(min_cost, dist2[P[i]]); return min_cost; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...