This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define ll long long
#include <bits/stdc++.h>
#include "cyberland.h"
using namespace std;
const ll N=1e5+9;
ll vis[N],a[N],g;
pair<ll,ll>p;
vector<pair<ll,ll>>v[N];
vector<ll>o;
priority_queue<pair<ll,ll>>q;
void dfs(ll nd)
{
if(vis[nd])return;
vis[nd]=1;
if(!a[nd])o.push_back(nd);
for(auto i:v[nd])dfs(i.second);
}
double solve(int n, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) {
vector<ll>dis(n,1e18);
double ans=1e9+9;
for(ll i=0;i<n;++i)
{
a[i]=arr[i];
vis[i]=0,v[i].clear();
}
for(ll i=0;i<M;++i)
{
v[x[i]].push_back({c[i],y[i]});
v[y[i]].push_back({c[i],x[i]});
}
dfs(0);
for(ll i=0;i<n;++i)vis[i]=0;
dis[H]=0;
q.push({0,H});
while(q.size())
{
p=q.top();
g=p.second;
q.pop();
if(vis[g])continue;
vis[g]=1;
for(auto i:v[g])
{
if(dis[g]+i.first<dis[i.second])
{
dis[i.second]=dis[g]+i.first;
q.push({-dis[i.second],i.second});
}
}
}
o.push_back(0);
for(auto i:o)ans=min(ans,double(dis[i]));
if(ans==1e9+9)ans=-1;
return ans;
}
# | 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... |