Submission #335759

#TimeUsernameProblemLanguageResultExecution timeMemory
335759nikatamlianiCrocodile's Underground City (IOI11_crocodile)C++14
100 / 100
1112 ms75336 KiB
#include "crocodile.h" #include <bits/stdc++.h> using namespace std; int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { priority_queue<pair<int,int>> q; vector<vector<pair<int,int>>> edges(N); for(int i = 0; i < M; ++i) { edges[R[i][0]].push_back({R[i][1], L[i]}); edges[R[i][1]].push_back({R[i][0], L[i]}); } vector<bool> seen(N), vis(N); vector<int> dist(N); for(int i = 0; i < K; ++i) { q.push({0, P[i]}); seen[P[i]] = 1; } while(!q.empty()) { pair<int,int> p = q.top(); q.pop(); if(!seen[p.second]) { seen[p.second] = 1; continue; } if(vis[p.second]) continue; vis[p.second] = true; dist[p.second] = -p.first; for(pair<int,int> to : edges[p.second]) { q.push({-to.second+p.first, to.first}); } } return dist[0]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...