Submission #672358

#TimeUsernameProblemLanguageResultExecution timeMemory
672358Hacv16Crocodile's Underground City (IOI11_crocodile)C++17
100 / 100
535 ms133916 KiB
#include<bits/stdc++.h> //#include "crocodile.h" using namespace std; typedef long long ll; const int MAX = 2e6 + 15; const int INF = 0x3f3f3f3f; #define fr first #define sc second ll dist[MAX][2], ans; bool seen[MAX]; vector<pair<ll, ll>> adj[MAX]; int travel_plan(int n, int m, int R[][2], int L[], int k, int P[]){ for(int i = 0; i < m; i++){ ll u = R[i][0], v = R[i][1], w = L[i]; adj[u].push_back({v, w}); adj[v].push_back({u, w}); } for(int i = 0; i < n; i++) dist[i][0] = dist[i][1] = INF; priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> q; for(int i = 0; i < k; i++){ dist[P[i]][0] = dist[P[i]][1] = 0; q.push({0, P[i]}); } while(q.size()){ ll u = q.top().sc; q.pop(); if(seen[u]) continue; seen[u] = true; for(auto e : adj[u]){ ll v = e.fr, w = e.sc; if(dist[u][1] + w < dist[v][0]){ dist[v][1] = dist[v][0]; dist[v][0] = dist[u][1] + w; q.push({dist[v][1], v}); }else if(dist[u][1] + w < dist[v][1]){ dist[v][1] = dist[u][1] + w; q.push({dist[v][1], v}); } } } return dist[0][1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...