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;
int N, M, K, H, A[100005];
double D1[100005], D2[100005], D3[100005];
vector<pair<int, int>> adj[100005];
double solve(int n, int m, int k, int h, vector<int> x,
vector<int> y, vector<int> c, vector<int> arr) {
for(int l = 0; l < n; l++)
D1[l] = INT_MAX, adj[l].clear();
D1[0] = 0;
for(int l = 0; l < m; l++) {
adj[x[l]].push_back({y[l], c[l]});
adj[y[l]].push_back({x[l], c[l]});
}
priority_queue<pair<double, int>,
vector<pair<double, int>>, greater<pair<double, int>>> pq;
pq.push({0, 0});
while(!pq.empty()) {
double W = pq.top().first;
int U = pq.top().second; pq.pop();
if(U == h) continue;
for(auto V : adj[U]) {
if(D1[V.first] > W + V.second) {
D1[V.first] = W + V.second;
if(arr[V.first] == 0) D1[V.first] = 0;
pq.push({D1[V.first], V.first});
}
}
}
if(D1[h] == INT_MAX) return -1;
return D1[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... |