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 "cyberland.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define sz(a) (int)a.size()
#define all(x) (x).begin(), (x).end()
double solve(int n, int m, int k, int h, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) {
vector<ll> dp(n, -1);
vector<vector<pair<ll, ld>>> adj(n);
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<pair<ll, ld>, vector<pair<ll, ld>>, greater<pair<ll, ld>>> q;
q.push({0, 0});
while(!q.empty()){
ll cst=q.top().S, nw=q.top().F;
q.pop();
if(arr[nw]==0) cst=0;
if(arr[nw]==2) cst/=2;
if(dp[nw]<=cst && dp[nw]!=-1) continue;
dp[nw]=cst;
for(auto& u : adj[nw]){
if(dp[u.F]==-1 || dp[u.F]>cst+u.S){
q.push({u.F, cst+u.S});
}
}
}
return dp[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... |