# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
438435 | 2021-06-28T02:25:10 Z | Deepesson | Crocodile's Underground City (IOI11_crocodile) | C++17 | 0 ms | 0 KB |
#include <bits/stdc++.h> #define MAX 101000 typedef std::pair<int,int> pii; std::vector<pii> con[MAX]; int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0); int N,M,K; std::cin>>N>>M>>K; for(int i=0;i!=M;++i){ int a,b,c;std::cin>>a>>b>>c; con[a].push_back({b,c}); con[b].push_back({a,c}); } std::priority_queue<pii,std::vector<pii>,std::greater<pii>> queue; int peso_min[N]={}; int visitas[N]={}; for(int i=0;i!=K;++i){ int x;std::cin>>x; visitas[x]=1;queue.push({0,x}); } while(queue.size()){ auto _=queue.top(); queue.pop(); if(!visitas[_.second]){ ++visitas[_.second]; }else if(visitas[_.second]==1){ ++visitas[_.second]; peso_min[_.second]=_.first; for(auto&k:con[_.second]){ queue.push({k.second+_.first,k.first}); } } } std::cout<<peso_min[0]<<"\n"; }