#include "cyberland.h"
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
//g++ cyberland.cpp cyberland.h stub.cpp
const int N = 1e5 + 69;
const long long inf = 1e18;
vector<pair<int, int>> g[N];
double dis[N][33];
double solve(int n, int m, int k, int s, vector<int> x, vector<int> y, vector<int> c, vector<int> a) {
//reset
for (int i = 0;i < n;i++)
g[i].clear();
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]});
}
for (int i = 1;i < n;i++) {
for (int j = 0;j <= k;j++)
dis[i][j] = inf;
}
priority_queue<tuple<double, int, int>> pq;
pq.push({0, 0, 0});
while (!pq.empty()) {
auto x = pq.top();
pq.pop();
int v, j;
double d;
tie(d, v, j) = x;
d = abs(d);
if (a[v] == 0) {
for (int j = 0;j <= k;j++)
dis[v][j] = 0;
d = 0;
}
for (auto u : g[v]) {
if (dis[u.f][j] > d + u.s) {
dis[u.f][j] = d + u.s;
if (u.f != s)
pq.push({-dis[u.f][j], u.f, j});
}
if (a[u.f] == 2) {
if (j < k && dis[u.f][j + 1] > (d + u.s) / 2) {
dis[u.f][j + 1] = (d + u.s) / 2;
if (u.f != s)
pq.push({-dis[u.f][j + 1], u.f, j + 1});
}
}
}
}
double ans = inf;
for (int i = 0;i <= k;i++)
ans = min(ans, dis[s][i]);
if (ans == inf)
ans = -1;
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
3932 KB |
Correct. |
2 |
Correct |
12 ms |
4188 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
6236 KB |
Correct. |
2 |
Correct |
18 ms |
6168 KB |
Correct. |
3 |
Correct |
18 ms |
5980 KB |
Correct. |
4 |
Correct |
19 ms |
5976 KB |
Correct. |
5 |
Correct |
21 ms |
6236 KB |
Correct. |
6 |
Correct |
17 ms |
8792 KB |
Correct. |
7 |
Correct |
21 ms |
8796 KB |
Correct. |
8 |
Correct |
11 ms |
11608 KB |
Correct. |
9 |
Correct |
16 ms |
3932 KB |
Correct. |
10 |
Correct |
16 ms |
3928 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
5980 KB |
Correct. |
2 |
Correct |
20 ms |
5976 KB |
Correct. |
3 |
Correct |
19 ms |
6236 KB |
Correct. |
4 |
Correct |
18 ms |
3932 KB |
Correct. |
5 |
Correct |
18 ms |
3928 KB |
Correct. |
6 |
Correct |
5 ms |
6488 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
23900 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
6236 KB |
Correct. |
2 |
Correct |
17 ms |
6244 KB |
Correct. |
3 |
Correct |
17 ms |
6236 KB |
Correct. |
4 |
Correct |
17 ms |
8796 KB |
Correct. |
5 |
Correct |
14 ms |
3676 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
6232 KB |
Correct. |
2 |
Correct |
21 ms |
6232 KB |
Correct. |
3 |
Correct |
32 ms |
29520 KB |
Correct. |
4 |
Correct |
14 ms |
6748 KB |
Correct. |
5 |
Correct |
20 ms |
3928 KB |
Correct. |
6 |
Correct |
18 ms |
6232 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
921 ms |
10248 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3096 ms |
77736 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |