Submission #388934

#TimeUsernameProblemLanguageResultExecution timeMemory
388934Killer2501Crocodile's Underground City (IOI11_crocodile)C++14
100 / 100
653 ms79092 KiB
#include <bits/stdc++.h> #define ll long long //#include "crocodile.h" #define pb push_back #define task "asd" #define pll pair<ll, ll> #define pii pair<pll, ll> #define fi first #define se second using namespace std; const ll mod = 1e17+7; const ll N = 2e5+5; const int base = 313; int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]) { ll a[n], d[n][2]; vector<pll> adj[n]; for(int i = 0; i < m; i ++) { ll x, y, z; x = r[i][1]; y = r[i][0]; z = l[i]; adj[x].pb({z, y}); adj[y].pb({z, x}); } priority_queue< pll, vector<pll>, greater<pll> > pq; for(int i = 0; i < n; i ++) { d[i][0] = d[i][1] = mod; a[i] = 0; } for(int i = 0; i < k; i ++) { ll x = p[i]; d[x][1] = d[x][0] = 0; a[x] = 0; pq.push({0, x}); } while(!pq.empty()) { pll u = pq.top(); pq.pop(); if(a[u.se] == 1) { continue; } ++a[u.se]; for(pll v : adj[u.se]) { ll val = v.fi + u.fi; if(val <= d[v.se][0]) { d[v.se][1] = d[v.se][0]; d[v.se][0] = val; if(d[v.se][1] != mod)pq.push({d[v.se][1], v.se}); } else if(val < d[v.se][1]) { d[v.se][1] = val; pq.push({d[v.se][1], v.se}); } } } return d[0][1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...