Submission #731360

#TimeUsernameProblemLanguageResultExecution timeMemory
731360lucriCrocodile's Underground City (IOI11_crocodile)C++17
100 / 100
489 ms61320 KiB
#include "crocodile.h" #include <bits/stdc++.h> int time1[100010],time2[100010],n,m; std::vector<std::vector<std::pair<int,int>>>a; std::priority_queue<std::pair<int,int>>q; bool viz[100010]; void lee() { while(!q.empty()) { int val=-q.top().first; int nod=q.top().second; q.pop(); if(viz[nod]==true) continue; viz[nod]=true; for(auto x:a[nod]) { if(time1[x.first]==0||time1[x.first]>val+x.second) { time2[x.first]=time1[x.first]; time1[x.first]=val+x.second; if(time2[x.first]!=0) q.push({-time2[x.first],x.first}); } else if(time2[x.first]==0||time2[x.first]>val+x.second) { time2[x.first]=val+x.second; q.push({-time2[x.first],x.first}); } } } } int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { n=N; m=M; a.resize(n+5); for(int i=0;i<m;++i) { a[R[i][0]].push_back({R[i][1],L[i]}); a[R[i][1]].push_back({R[i][0],L[i]}); } for(int i=0;i<K;++i) { time1[P[i]]=time2[P[i]]=1; q.push({-1,P[i]}); } lee(); return time2[0]-1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...