Submission #562641

#TimeUsernameProblemLanguageResultExecution timeMemory
562641IwanttobreakfreeCrocodile's Underground City (IOI11_crocodile)C++98
89 / 100
494 ms44768 KiB
#include <iostream> #include <vector> #include <queue> #include "crocodile.h" using namespace std; typedef long long ll; int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){ vector<pair<int,int>> d(N,{1e9+1,1e9+1}); vector<vector<pair<int,int>>> g(N,vector<pair<int,int>>()); for(int i=0;i<M;i++){ g[R[i][0]].push_back({R[i][1],L[i]}); g[R[i][1]].push_back({R[i][0],L[i]}); } priority_queue<pair<int,int>> pq; for(int i=0;i<K;i++){ pq.push({0,P[i]}); d[P[i]].first=d[P[i]].second=0; } while(!pq.empty()){ int dist=-pq.top().first,u=pq.top().second; pq.pop(); //cout<<u<<' '; if(dist!=d[u].second)continue; for(auto v:g[u]){ if(dist+v.second<d[v.first].first){ d[v.first].second=d[v.first].first; d[v.first].first=dist+v.second; if(d[v.first].second<=1e9)pq.push({-d[v.first].second,v.first}); } else if(dist+v.second<d[v.first].second){ d[v.first].second=dist+v.second; pq.push({-d[v.first].second,v.first}); } } } return d[0].second; } /*int main(){ int n,m,k; cin>>n>>m>>k; int R[m][2],l[m],e[k]; for(int i=0;i<m;i++)cin>>R[i][0]>>R[i][1]>>l[i]; for(int i=0;i<k;i++)cin>>e[i]; cout<<travel_plan(n,m,R,l,k,e); }*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...