#include <bits/stdc++.h>
#include "cyberland.h"
using namespace std;
double solve(int n, int m, int k, int h, vector<int> x,
vector<int> y, vector<int> c, vector<int> arr) {
double d[n]; d[0] = 0;
for(int l = 1; l < n; l++) d[l] = INT_MAX;
vector<pair<int, int>> adj[n];
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();
for(auto v : adj[u]) {
if(d[v.first] > w + v.second) {
d[v.first] = w + v.second;
if(arr[v.first] == 0) d[v.first] = 0;
if(v.first != h) pq.push({d[v.first], v.first});
}
}
}
if(d[h] == INT_MAX) return -1;
return d[h];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
468 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
472 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
428 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
5708 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
468 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
24 ms |
468 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
28 ms |
468 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
26 ms |
408 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |