Submission #67565

#TimeUsernameProblemLanguageResultExecution timeMemory
67565Hoget157Crocodile's Underground City (IOI11_crocodile)C++14
100 / 100
993 ms118764 KiB
#include "crocodile.h" #include <bits/stdc++.h> #define ll long long #define INF 1e+18 #define pb push_back using namespace std; struct edge{ ll to,cost; }; typedef pair<int,int> P; ll n,m,d1[100010],d2[100010]; vector<edge> G[100010]; int travel_plan(int N, int M, int R[][2], int L[], int K, int Q[]){ n = N,m = M; for(int i = 0;i < n;i++){ d1[i] = INF; d2[i] = INF; } for(int i = 0;i < m;i++){ G[R[i][0]].pb({R[i][1],L[i]}); G[R[i][1]].pb({R[i][0],L[i]}); } priority_queue<P,vector<P>,greater<P>> que; for(int i = 0;i < K;i++){ d1[Q[i]] = 0; d2[Q[i]] = 0; que.push(P(0,Q[i])); } while(!que.empty()){ P p = que.top();que.pop(); ll v = p.second; if(d2[v] < p.first) continue; for(edge e : G[v]){ ll cost = d2[v] + e.cost; if(d1[e.to] > cost) swap(d1[e.to],cost); if(d2[e.to] > cost){ d2[e.to] = cost; que.push(P(d2[e.to],e.to)); } } } return d2[0]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...