This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//we are all lost trying to be someone.
#include <bits/stdc++.h>
#include "cyberland.h"
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define sz(x) ll(x.size())
#define reve(x) reverse(x.begin(),x.end())
#define ff first
#define ss second
using namespace std;
typedef int ll;
typedef long double ld;
typedef pair<double,ll> ii;
const ll MAX=(1e5+10)*2;
vector<ii> gfo[MAX];
bool vst[MAX];
double dist[MAX];
void dikstra(ll ini){
set<ii> q;
q.insert({0,ini});
vst[ini]=true;
dist[ini]=0.0;
while(sz(q)){
ii x=*q.begin();
q.erase(q.begin());
ll u=x.ss;
ll dist_u=x.ff;
if(dist[u]!=dist_u)continue;
for(ii y:gfo[u]){
ll v=y.ss;
ll w=y.ff;
if(dist[v]>dist[u]+w){
dist[v]=dist[u]+w;
q.insert({dist[v],v});
}
}
}
return;
}
double solve(ll N, ll M, ll K,ll H, vector<ll> x, vector<ll> y, vector<ll> c, vector<ll> arr){
cout<<fixed<<setprecision(10);
for(ll i=0; i<=N; i++){
dist[i]=10000000000.0;
}
for(ll i=0; i<M; i++){
gfo[x[i]].push_back({c[i],y[i]});
gfo[y[i]].push_back({c[i],x[i]});
}
dikstra(0);
return dist[H];
}
/*
int main(){
ll N,M,K,H;
vector<ll> x,y,c,arr;
cin>>N>>M>>K>>H;
for(ll j=0; j<3; j++) for(ll i=0; i<M; i++){
ll a;
cin>>a;
if(j==0)x.push_back(a);
else if(j==1)y.push_back(a);
else c.push_back(a);
}
for(ll i=0; i<N; i++){
ll a;
cin>>a;
arr.push_back(a);
}
cout<<solve(N,M,K,H,x,y,c,arr)<<'\n';
return 0;
}*/
# | 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... |