#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
const int nx=1e5+5, kx=31;
priority_queue<pair<double, pair<int, double>>, vector<pair<double, pair<int, double>>>, greater<pair<double, pair<int, double>>>> pq;
double dp[nx][kx], ans=DBL_MAX;
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) {
vector<vector<pair<int, int>>> d(nx);
for (int i=0; i<M; i++) d[x[i]].push_back({y[i], c[i]}), d[y[i]].push_back({x[i], c[i]});
for (int i=0; i<N; i++) if (arr[i]==0) pq.push({0, {0, i}});
for (int i=0; i<N; i++)
{
if (arr[i]!=0) for (int j=0; j<kx; j++) dp[i][j]=DBL_MAX;
else for (int j=0; j<kx; j++) dp[i][j]=0;
}
dp[0][0]=0;
pq.push({0, {0, 0}});
while (!pq.empty())
{
auto cw=pq.top().first, cl=pq.top().second.second;
auto ck=pq.top().second.first;
pq.pop();
//cout<<cw<<' '<<ck<<' '<<cl<<'\n';
if (cl==H) continue;
for (auto [v, w]:d[cl])
{
if (dp[v][ck]>cw+w) pq.push({cw+w, {ck, v}}), dp[v][ck]=cw+w;
if (arr[v]==2&&ck!=K) if (dp[v][ck+1]>(cw+w)/2) pq.push({(cw+w)/2, {ck+1, v}}), dp[v][ck+1]=(cw+w)/2;
}
}
for (int i=0; i<=K; i++) ans=min(ans, dp[H][i]);
if (ans==DBL_MAX) return -1;
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1711 ms |
2900 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
47 ms |
5292 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
53 ms |
5292 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
636 ms |
32780 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
44 ms |
5292 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
45 ms |
5360 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
271 ms |
3588 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
597 ms |
4340 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |