# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1059102 | vjudge1 | Cyberland (APIO23_cyberland) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
long long dist[100001];
void dijkstra(vector<pair<long long,long long>> adj[],long long i)
{
priority_queue<pair<long long,long long>> pq;
pq.push({-0,i});
dist[i]=0;
while(pq.size()>0)
{
long long a=-pq.top().first,b=pq.top().second;
pq.pop();
for(auto it : adj[b])
{
if(dist[it.first]==-1 || (dist[it.first]>a+it.second))
{
dist[it.first]=dist[b]+it.second;
pq.push({-dist[it.first],it.first});
}
}
}
}
double solve(long long N, long long M, long long K, long long H, std::vector<long long> x, std::vector<long long>
y, std::vector<long long> c, std::vector<long long> arr)
{
memset(dist,-1,sizeof(dist));
vector<pair<long long,long long>> adj[N+1];
for(long long i=0;i<x.size();i++)
{
long long a=x[i],b=y[i],cc=c[i];
adj[a].push_back({b,cc});
adj[b].push_back({a,cc});
}
dijkstra(adj,0);
return dist[H];
}