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],g;
pair<ll,ll>p;
vector<pair<ll,ll>>v[N];
priority_queue<pair<ll,ll>>q;
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=-1;
for(ll i=0;i<n;++i)
{
if(!arr[i])dis[i]=0;
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]});
}
dis[0]=0;
q.push({0,0});
while(q.size())
{
p=q.top();
g=p.second;
q.pop();
if(vis[g])continue;
vis[g]=1;
if(!arr[g])dis[g]=0;
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});
}
}
}
if(dis[H]<1e18)ans=dis[H];
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... |