#include <bits/stdc++.h>
using namespace std;
#define pb push_back
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> a) {
const double INF = DBL_MAX;
vector<vector<pair<int,double>>> g(n);
for(int i = 0;i < m;i++){
g[x[i]].pb({y[i],c[i]});
g[y[i]].pb({x[i],c[i]});
}
set<tuple<double,int,int>> q;
q.insert({0,0,k});
double dis[n][k + 1];
for(int i = 0;i < n;i++){
for(int j = 0;j <= k;j++){
dis[i][j] = INF;
}
}
dis[0][k] = 0;
while(!q.empty()){
auto [cost,v,nk] = *q.begin();q.erase(*q.begin());
if(dis[v][nk] < cost) continue;
if(v == h) return cost;
for(auto [to,w] : g[v]){
double newtime = cost + w;
if(a[to] == 0) newtime = 0;
if(newtime < dis[to][nk]){
dis[to][nk] = newtime;
q.insert({newtime,to,nk});
}
if(a[to] == 2 && nk > 0){
double time = newtime / 2;
if(time < dis[to][nk - 1]){
dis[to][nk - 1] = time;
q.insert({time,to,nk - 1});
}
}
}
}
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
856 KB |
Correct. |
2 |
Correct |
16 ms |
1100 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
1628 KB |
Correct. |
2 |
Correct |
26 ms |
1624 KB |
Correct. |
3 |
Correct |
24 ms |
1372 KB |
Correct. |
4 |
Correct |
25 ms |
1564 KB |
Correct. |
5 |
Correct |
25 ms |
1628 KB |
Correct. |
6 |
Correct |
20 ms |
4512 KB |
Correct. |
7 |
Correct |
29 ms |
4272 KB |
Correct. |
8 |
Correct |
15 ms |
7772 KB |
Correct. |
9 |
Correct |
25 ms |
1108 KB |
Correct. |
10 |
Correct |
25 ms |
1064 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
26 ms |
1400 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
194 ms |
21544 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
1628 KB |
Correct. |
2 |
Correct |
25 ms |
1432 KB |
Correct. |
3 |
Correct |
26 ms |
1372 KB |
Correct. |
4 |
Correct |
22 ms |
4544 KB |
Correct. |
5 |
Correct |
21 ms |
1156 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
24 ms |
1372 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
465 ms |
3784 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1027 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |