#include <iostream>
#include <vector>
#include <queue>
#include <iomanip>
using namespace std;
vector<pair<int, int>> g[100005];
long double f[100005][35], d[100005][35];
int dd[100005];
long double solve(int n, int m, int k, int h, vector<int> x, vector<int> y, vector<int> c, vector<int> a) {
vector<int> v;
for (int i = 0; i < n; i++) g[i].clear();
for (int i = 0; i < n; i++) {
dd[i] = 0;
for (int j = 0; j <= k; j++) {
f[i][j] = 1e18;
}
}
for (int i = 0; i < m; i++) {
g[x[i]].push_back({y[i], c[i]});
g[y[i]].push_back({x[i], c[i]});
}
queue<int> q;
q.push(0);
dd[0] = 1;
while (!q.empty()) {
int p = q.front();
q.pop();
if (p == h) continue;
if (a[p] == 0) v.push_back(p);
for (auto w : g[p]) {
if (dd[w.first] == 0) {
dd[w.first] = 1;
q.push(w.first);
}
}
}
if (dd[h] == 0) return -1;
for (int w : v) f[w][0] = 0;
f[0][0] = 0;
for (int i = 0; i <= k; i++) {
priority_queue<pair<long double, int>> q;
if (i != 0) {
for (int j = 0; j < n; j++) {
for (auto w : g[j]) {
if (w.first == h) continue;
f[j][i] = min(d[w.first][i] + w.second, f[j][i]);
}
//cout << j << " " << i << " " << f[j][i] << " " << d[2][1] << '\n';
}
}
for (int j = 0; j < n; j++) {
if (j != h) {
q.push({-f[j][i], j});
}
}
while (!q.empty()) {
long double x = -q.top().first;
int u = q.top().second;
q.pop();
if (f[u][i] != x || u == h) continue;
//cout << u << " " << i << " " << x << " " << f[h][i] << " 328762836" << '\n';
for (auto w : g[u]) {
if (f[w.first][i] > f[u][i] + w.second) {
f[w.first][i] = f[u][i] + w.second;
q.push({-f[w.first][i], w.first});
}
}
}
if (i == k) break;
for (int j = 0; j < n; j++) {
if (a[j] <= 1) d[j][i + 1] = f[j][i];
else if (a[j] == 2) d[j][i + 1] = f[j][i] / 2;
}
}
long double res = 1e18;
for (int j = 0; j <= k; j++) {
res = min(res, f[h][j]);
}
if (res > 1e17) return -1;
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
45 ms |
8264 KB |
Double -8.03469e+59 violates the range [-1, 1e+18] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
273 ms |
10176 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
321 ms |
10064 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1118 ms |
78596 KB |
Double -1.35948e+162 violates the range [-1, 1e+18] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
156 ms |
10148 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
181 ms |
10064 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
186 ms |
10240 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3068 ms |
18208 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |