Submission #262146

#TimeUsernameProblemLanguageResultExecution timeMemory
262146nandonathanielCrocodile's Underground City (IOI11_crocodile)C++14
100 / 100
1295 ms78412 KiB
#include "crocodile.h" #include "bits/stdc++.h" using namespace std; typedef pair<int,int> pii; typedef pair<long long,int> pli; const int MAXN=100005; const long long INF=1e18; vector<pii> adj[MAXN]; long long dist[MAXN]; priority_queue<pli,vector<pli>,greater<pli> > PQ; bool keluar[MAXN]; int muncul[MAXN]; int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { for(int i=0;i<M;i++){ adj[R[i][0]].push_back({R[i][1],L[i]}); adj[R[i][1]].push_back({R[i][0],L[i]}); } for(int i=0;i<N;i++)dist[i]=INF; for(int i=0;i<K;i++){ dist[P[i]]=0; keluar[P[i]]=true; PQ.push({dist[P[i]],P[i]}); } while(!PQ.empty()){ pii now=PQ.top(); PQ.pop(); muncul[now.second]++; if(!keluar[now.second]){ if(muncul[now.second]!=2)continue; } else{ if(muncul[now.second]!=1)continue; } dist[now.second]=now.first; for(auto nxt : adj[now.second]){ PQ.push({dist[now.second]+nxt.second,nxt.first}); } } return dist[0]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...