Submission #951152

#TimeUsernameProblemLanguageResultExecution timeMemory
951152irmuunCrocodile's Underground City (IOI11_crocodile)C++17
100 / 100
390 ms58024 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() int travel_plan(int N,int M,int R[][2],int L[],int K,int P[]){ vector<pair<int,int>>adj[N]; for(int i=0;i<M;i++){ adj[R[i][0]].pb({R[i][1],L[i]}); adj[R[i][1]].pb({R[i][0],L[i]}); } vector<int>mn1(N,2e9),mn2(N,2e9); vector<bool>end(N,false); priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>pq; for(int i=0;i<K;i++){ end[P[i]]=true; pq.push({0,P[i]}); } while(!pq.empty()){ auto [D,i]=pq.top(); pq.pop(); if(mn2[i]<D) continue; for(auto [j,l]:adj[i]){ if(!end[j]){ int newdist=D+l,bef=mn2[j]; if(newdist<mn1[j]){ mn2[j]=mn1[j]; mn1[j]=newdist; } else{ mn2[j]=min(mn2[j],newdist); } if(bef!=mn2[j]){ pq.push({mn2[j],j}); } } } } return mn2[0]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...