Submission #1048665

#TimeUsernameProblemLanguageResultExecution timeMemory
1048665MarwenElarbiCrocodile's Underground City (IOI11_crocodile)C++17
100 / 100
298 ms77636 KiB
#include <bits/stdc++.h> using namespace std; #include "crocodile.h" #define pb push_back #define fi first #define se second const int nax=1e5+5; vector<pair<int,int>> adj[nax]; 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]].pb({R[i][1],L[i]}); adj[R[i][1]].pb({R[i][0],L[i]}); } priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq; int vis[N]; memset(vis,0,sizeof vis); for (int i = 0; i < K; ++i) { pq.push({0,P[i]}); vis[P[i]]++; } while(!pq.empty()){ pair<int,int> node=pq.top(); pq.pop(); if(vis[node.se]++ == 1){ if(node.se==0) return node.fi; for(auto u:adj[node.se]){ pq.push({u.se+node.fi,u.fi}); } } } return N; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...