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>
#include "cyberland.h"
using namespace std;
#define lim 100005
#define OYY INT_MAX
#define fi first
#define se second
int n,m,k,h;
int vis[lim],dist[lim];
vector<pair<int,int>> v[lim];
inline int dij(int node){
for(int i=0;i<n;i++){
vis[i]=0;
dist[i]=OYY;
}
priority_queue<pair<int,int>> pq;
pq.push({0,0}); // cur distance --- cur node
dist[0]=0;
while(!pq.empty()){
int node=pq.top().se;
pq.pop();
if(vis[node])continue;
vis[node]=1;
for(auto go:v[node]){
if(dist[node]+go.se<dist[go.fi]){
dist[go.fi]=dist[node]+go.se;
pq.push({-dist[go.fi],go.fi});
}
}
}
return dist[h];
}
double solve(int N, int M, int K, int H,vector<int> x,vector<int> y,vector<int> c,vector<int> arr) {
n=N;m=M;k=K;h=H;
for(int i=0;i<m;i++){
v[x[i]].push_back({y[i],c[i]});
v[y[i]].push_back({x[i],c[i]});
}
int cev=dij(0);
for(int i=0;i<n;i++){
v[i].clear();
}
return cev;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |