#include <vector>
using namespace std;
#define vi vector<int>
#define pi pair<int,int>
#define x first
#define y second
#include "cyberland.h"
#define pd pair<double,double>
#define pdi pair<double,int>
#define vd vector<double>
#include <vector>
#include <queue>
void dfs(vector<bool>&vis, int i, int H,vector<vector<pdi>>&fr) {
if (i ==H)return;
if (vis[i])return;
vis[i] = 1;
for (pdi p : fr[i]) {
dfs(vis, p.y, H, fr);
}
}
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) {
K = min(K, 69);
vector<vd> dp(N, vd(K + 2,1e15));
vector<vector<pdi>> fr(N);
for (int i = 0; i < M; i++) {
fr[X[i]].push_back({ c[i],Y[i] });
fr[Y[i]].push_back({ c[i],X[i] });
}
priority_queue<pair<int,pdi>> pq;
vi fre;
vector<bool> vis(N);
dfs(vis, 0,H,fr);
pq.push({ 0,{0,0} });
for (int i = 0; i < N; i++)if (vis[i] == 1 && arr[i] == 0)pq.push({ 0,{0,i} });
while (!pq.empty()) {
pair<int, pdi> q = pq.top();
int s = q.x;
pdi p = q.y;
pq.pop();
if ((- s) > K)continue;
if (dp[p.y][-s] < -p.x)continue;
dp[p.y][-s] = -p.x;
if (p.y == H)continue;
for (pd f : fr[p.y]) {
if(arr[p.y]==2)pq.push({ s - 1,{p.x / 2 - f.x,f.y} });
if(f.x-p.x < dp[-s][f.y])pq.push({ s,{p.x - f.x,f.y} });
}
}
double mini = 1e15;
for (int i = 0; i <= K; i++)mini = min(mini, dp[H][i]);
if(mini==1e15)return -1;
return mini;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
860 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
644 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
183 ms |
24408 KB |
Correct. |
2 |
Runtime error |
47 ms |
1364 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
860 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
28 ms |
860 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
201 ms |
1332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
213 ms |
1616 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |