Submission #963278

#TimeUsernameProblemLanguageResultExecution timeMemory
963278SuPythonyCrocodile's Underground City (IOI11_crocodile)C++17
0 / 100
8 ms12636 KiB
#include "crocodile.h" #include <bits/stdc++.h> using namespace std; vector<vector<pair<int,int>>> al(100000, vector<pair<int,int>>()); vector<int> vis(100000,0); int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { for (int i=0; i<M; i++) { int u=R[i][0], v=R[i][1]; al[u].push_back({v, L[i]}); al[v].push_back({u, L[i]}); } vector<vector<int>> time(100000, vector<int>(2, INT_MAX)); priority_queue<pair<int,int>,vector<pair<int,int>>,greater<>> pq; for (int i=0; i<K; i++) { pq.push({0,P[i]}); time[P[i]][0]=time[P[i]][1]=0; vis[P[i]]=1; } while (!pq.empty()) { int u=pq.top().second; pq.pop(); for (auto v: al[u]) { if (time[u][1]+v.second<=time[v.first][0]) { time[v.first][1]=time[v.first][0]; time[v.first][0]=time[u][1]+v.second; pq.push({time[v.first][1],v.first}); } else { if (time[u][1]+v.second<=time[v.first][1]) { time[v.first][1]=time[u][1]+v.second; pq.push({time[v.first][1],v.first}); } } } } return time[0][1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...