#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;
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});
}
}
}
}
double ans = INF;
for(int i = 0;i <= k;i++){
ans = min(ans,dis[h][i]);
}
if(ans == INF) ans = -1;
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
22 ms |
860 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
1728 KB |
Correct. |
2 |
Correct |
28 ms |
1992 KB |
Correct. |
3 |
Correct |
28 ms |
1824 KB |
Correct. |
4 |
Correct |
27 ms |
1628 KB |
Correct. |
5 |
Correct |
27 ms |
1884 KB |
Correct. |
6 |
Correct |
26 ms |
4800 KB |
Correct. |
7 |
Correct |
35 ms |
4784 KB |
Correct. |
8 |
Correct |
15 ms |
7772 KB |
Correct. |
9 |
Correct |
25 ms |
1368 KB |
Correct. |
10 |
Correct |
25 ms |
1424 KB |
Correct. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
28 ms |
1616 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1413 ms |
21924 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
1592 KB |
Correct. |
2 |
Correct |
24 ms |
1880 KB |
Correct. |
3 |
Correct |
24 ms |
1628 KB |
Correct. |
4 |
Correct |
24 ms |
4808 KB |
Correct. |
5 |
Correct |
23 ms |
1116 KB |
Correct. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
25 ms |
1832 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
562 ms |
3764 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1006 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |