#include <bits/stdc++.h>
#include "cyberland.h"
// #include "stub.cpp"
using namespace std;
#define ff first
#define ss second
#define pii pair<int, int>
double solve(int n, int M, int K, int H, vector<int> X, vector<int> Y, vector<int> C, vector<int> a) {
vector<pii> E[n];
for (int i = 0; i < M; i++) {
E[X[i]].push_back({Y[i], C[i]});
E[Y[i]].push_back({X[i], C[i]});
}
queue<int> q;
vector<bool> vis0(n);
q.push(0); vis0[0] = true;
while (!q.empty()) {
int x = q.front(); q.pop();
if (x == H) continue;
for (auto [i, w] : E[x]) {
if (!vis0[i]) {
q.push(i);
vis0[i] = true;
}
}
}
if (!vis0[H]) return -1;
vector<vector<double>> dis(n, vector<double>((int)3e2 + 1, 1e18));
priority_queue<pair<double, pii>> pq;
for (int i = 0; i < n; i++) {
if (!i || (!a[i] && vis0[i])) {
dis[i][0] = 0;
pq.push({0, {i, 0}});
}
}
while (!pq.empty()) {
double d = pq.top().ff; d = -d;
auto [x, y] = pq.top().ss; pq.pop();
if (d != dis[x][y]) continue;
if (x == H) return d;
for (auto [i, w] : E[x]) {
if (!a[i]) continue;
if (d + w < dis[i][y]) {
dis[i][y] = d + w;
pq.push({-dis[i][y], {i, y}});
}
if (a[i] == 2 && y < (int)3e2 && (d + w) / 2 < dis[i][y + 1]) {
dis[i][y + 1] = (d + w) / 2;
pq.push({-dis[i][y + 1], {i, y + 1}});
}
}
}
assert(false);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
604 KB |
Correct. |
2 |
Correct |
18 ms |
492 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
48 ms |
2976 KB |
Correct. |
2 |
Correct |
52 ms |
2884 KB |
Correct. |
3 |
Correct |
49 ms |
2832 KB |
Correct. |
4 |
Correct |
57 ms |
3024 KB |
Correct. |
5 |
Correct |
56 ms |
3072 KB |
Correct. |
6 |
Correct |
47 ms |
24580 KB |
Correct. |
7 |
Correct |
63 ms |
24172 KB |
Correct. |
8 |
Correct |
28 ms |
48980 KB |
Correct. |
9 |
Correct |
32 ms |
748 KB |
Correct. |
10 |
Correct |
30 ms |
740 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
2904 KB |
Correct. |
2 |
Correct |
49 ms |
2936 KB |
Correct. |
3 |
Correct |
49 ms |
2916 KB |
Correct. |
4 |
Correct |
38 ms |
736 KB |
Correct. |
5 |
Correct |
36 ms |
732 KB |
Correct. |
6 |
Correct |
11 ms |
20316 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1800 ms |
178864 KB |
Correct. |
2 |
Incorrect |
2050 ms |
6184 KB |
Wrong Answer. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
2668 KB |
Correct. |
2 |
Correct |
30 ms |
2680 KB |
Correct. |
3 |
Correct |
30 ms |
2884 KB |
Correct. |
4 |
Correct |
34 ms |
24220 KB |
Correct. |
5 |
Correct |
19 ms |
720 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
2888 KB |
Correct. |
2 |
Correct |
24 ms |
2652 KB |
Correct. |
3 |
Correct |
29 ms |
7260 KB |
Correct. |
4 |
Correct |
21 ms |
14780 KB |
Correct. |
5 |
Correct |
22 ms |
744 KB |
Correct. |
6 |
Correct |
29 ms |
2744 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1428 ms |
18620 KB |
Correct. |
2 |
Correct |
172 ms |
16088 KB |
Correct. |
3 |
Incorrect |
215 ms |
244004 KB |
Wrong Answer. |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1436 ms |
16236 KB |
Correct. |
2 |
Correct |
180 ms |
14004 KB |
Correct. |
3 |
Correct |
169 ms |
247632 KB |
Correct. |
4 |
Incorrect |
1276 ms |
21112 KB |
Wrong Answer. |
5 |
Halted |
0 ms |
0 KB |
- |