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;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ll long long
#define pb push_back
#define uwu 100005
vector<pair<int,int>>adj[uwu];
long double solve(int N, int M, int K, int H, vector<int> x, vector<int>y, vector<int> c, vector<int> arr){
int father[N];
long double yol[N];
for(int i=0;i<N;i++){
father[i]=-1;
yol[i]=1000000000000000;
}
for(int i=0;i<M;i++){
adj[x[i]].pb({y[i],c[i]});
adj[y[i]].pb({x[i],c[i]});
}
priority_queue<tuple<double,int,int>> pq;
pq.push({-0.0,0,-1});
while(pq.size()){
ll int node,once;double deg;
tie(deg,node,once)=pq.top();deg=-deg;
pq.pop();
//cout<<node<<" "<<once<<" "<<" "<<deg<<" "<<endl;
if(yol[node]<=deg)continue;
if(arr[node]==0){
deg=0;
}
yol[node]=deg;
father[node]=once;
for(auto u:adj[node]){
int kim=u.first;double lira=u.second;
pq.push({-(deg+lira),kim,node});
}
}
/*for(int i=0;i<N;i++)cout<<yol[i]<<" ";
cout<<endl;
for(int i=0;i<N;i++)cout<<father[i]<<" ";
cout<<endl;*/
for(int i=0;i<N;i++)adj[i].clear();
if(father[H]==-1)yol[H]=-1;
return yol[H];
}
| # | 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... |