#include <bits/stdc++.h>
double solve(int N, int M, int K, int H, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr){
std::vector<std::vector<std::pair<int,int>>> adj(N);
for(int i = 0; i < M; i++) adj[x[i]].push_back({y[i],c[i]}),adj[y[i]].push_back({x[i],c[i]});
std::vector<std::pair<double,int>> res;
std::priority_queue<std::pair<int,int>> pq;
std::vector<double> dist(N,(int)1e20);
dist[H]=0;
pq.push({0,H-1});
while(!pq.empty()){
std::pair<int,int> nd = pq.top();
nd.first*=-1;
pq.pop();
for(int i = 0; i < (int)adj[nd.second].size(); i++){
if(dist[adj[nd.second][i].first]>nd.first+adj[nd.second][i].second){
dist[adj[nd.second][i].first] = nd.first+adj[nd.second][i].second;
if(arr[adj[nd.second][i].first]==1&&adj[nd.second][i].first!=0) pq.push({(nd.first+adj[nd.second][i].second)*-1,adj[nd.second][i].first});
else res.push_back({nd.first+adj[nd.second][i].second,adj[nd.second][i].first});
}
}
}
double r = (int)1e20;
for(int i = 0; i < (int)res.size(); i++){
r=std::min(res[i].first,r);
}
return r;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 ms |
600 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
604 KB |
Double -1.80122e+09 violates the range [-1, 1e+18] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
348 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
5724 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
600 KB |
Double -1.88673e+09 violates the range [-1, 1e+18] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
604 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
344 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
344 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |