Submission #113641

#TimeUsernameProblemLanguageResultExecution timeMemory
113641MercenaryCrocodile's Underground City (IOI11_crocodile)C++14
100 / 100
771 ms89416 KiB
#include "crocodile.h" #include<bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; const long long inf = (long long)1e18 + 5; typedef long long ll; typedef pair<ll,int> ii; #define pb push_back #define mp make_pair int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { priority_queue<ii,vector<ii>,greater<ii>> pq; vector<ll> d(N , inf) , d1(N , inf); vector<vector<ii>> adj(N); for(int i = 0 ; i < M ; ++i){ adj[R[i][0]].pb(mp(R[i][1] , L[i])); adj[R[i][1]].pb(mp(R[i][0] , L[i])); } for(int i = 0 ; i < K ; ++i){ d[P[i]] = d1[P[i]] = 0; pq.push(mp(0 , P[i])); } while(!pq.empty()){ auto u = pq.top();pq.pop(); // printf("%d %d\n",u.first,u.second); if(d1[u.second] != u.first)continue; for(ii c : adj[u.second]){ if(d[c.first] > u.first + c.second){ if(d1[c.first] != d[c.first]){ d1[c.first] = d[c.first]; pq.push(mp(d1[c.first] , c.first)); } d[c.first] = u.first + c.second; }else if(d1[c.first] > u.first + c.second){ d1[c.first] = u.first + c.second; pq.push(mp(d1[c.first] , c.first)); } } } return d1[0]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...