#include<bits/stdc++.h>
#include "cyberland.h"
#define int long long
#define dp dist
using namespace std;
const int K = 31;
const int N = 100010;
vector <pair <int, int>> g[N];
double dist[N][K][2];
int op[N];
double solve(int32_t n, int32_t m, int32_t k, int32_t h, std::vector<int32_t> x, std::vector<int32_t> y, std::vector<int32_t> c, std::vector<int32_t> arr) {
for(int i = 0;i < n;i++){
g[i].clear();
}
for(int i = 0;i < m;i++){
int a = x[i], b = y[i], w = c[i];
g[a].push_back({b, w});
g[b].push_back({a, w});
}
for(int i = 0;i < n;i++){
op[i] = arr[i];
}
for(int i = 0;i < n;i++){
for(int j = 0;j <= k;j++){
dist[i][j][0] = dist[i][j][1] = 1e18;
}
}
priority_queue <pair <double, array <int, 3>>> pq;
for(int i = 0;i <= k;i++){
dist[0][i][0] = 0;
pq.push({0, {0, i, 0}});
}
while(!pq.empty()){
auto [d,cu] = pq.top();
auto [v, i, flag] = cu;
pq.pop();
d *= -1;
if(d != dist[v][i][flag]) continue;
if(v == h) continue;
if(flag == 0){
if(op[v] == 0){
if(dist[v][i][1] > 0){
dist[v][i][1] = 0;
pq.push({-dist[v][i][1], {v, i, 1}});
}
}
else if(op[v] == 2){
if(i > 0){
if(dist[v][i-1][1] > (dist[v][i][0])/(2.0)){
dist[v][i-1][1] = (dist[v][i][0])/(2.0);
pq.push({-dist[v][i-1][1], {v, i-1, 1}});
}
}
}
else{
if(dist[v][i][1] > dist[v][i][0]){
dist[v][i][1] = dist[v][i][0];
pq.push({-dist[v][i][1], {v, i, 1}});
}
}
}
for(auto [x, w] : g[v]){
if(dist[v][i][flag]+w < dist[x][i][0]){
dist[x][i][0] = dist[v][i][flag]+w;
pq.push({-dist[x][i][0], {x, i, 0}});
}
}
}
double res = 1e18;
for(int i = 0;i <= k;i++){
res = min(res, dp[h][i][0]);
}
return (res == 1e18 ? -1 : res);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
67 ms |
2888 KB |
Correct. |
2 |
Correct |
62 ms |
2888 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
374 ms |
3876 KB |
Correct. |
2 |
Correct |
466 ms |
3876 KB |
Correct. |
3 |
Correct |
434 ms |
3916 KB |
Correct. |
4 |
Correct |
433 ms |
3892 KB |
Correct. |
5 |
Correct |
439 ms |
3880 KB |
Correct. |
6 |
Correct |
414 ms |
11468 KB |
Correct. |
7 |
Correct |
533 ms |
11276 KB |
Correct. |
8 |
Correct |
262 ms |
18108 KB |
Correct. |
9 |
Correct |
368 ms |
2952 KB |
Correct. |
10 |
Correct |
353 ms |
2896 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
662 ms |
4268 KB |
Correct. |
2 |
Correct |
636 ms |
5236 KB |
Correct. |
3 |
Correct |
602 ms |
5288 KB |
Correct. |
4 |
Correct |
529 ms |
3912 KB |
Correct. |
5 |
Correct |
533 ms |
3912 KB |
Correct. |
6 |
Correct |
133 ms |
11708 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
520 ms |
36064 KB |
Correct. |
2 |
Correct |
913 ms |
4464 KB |
Correct. |
3 |
Correct |
767 ms |
4420 KB |
Correct. |
4 |
Correct |
813 ms |
4424 KB |
Correct. |
5 |
Correct |
591 ms |
3912 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
208 ms |
4020 KB |
Correct. |
2 |
Correct |
207 ms |
4132 KB |
Correct. |
3 |
Correct |
230 ms |
3980 KB |
Correct. |
4 |
Correct |
248 ms |
12056 KB |
Correct. |
5 |
Correct |
174 ms |
3004 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
395 ms |
5068 KB |
Correct. |
2 |
Correct |
302 ms |
5692 KB |
Correct. |
3 |
Correct |
60 ms |
48456 KB |
Correct. |
4 |
Correct |
245 ms |
15352 KB |
Correct. |
5 |
Correct |
320 ms |
3852 KB |
Correct. |
6 |
Correct |
361 ms |
5936 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
814 ms |
6880 KB |
Correct. |
2 |
Correct |
126 ms |
10112 KB |
Correct. |
3 |
Correct |
2401 ms |
62020 KB |
Correct. |
4 |
Correct |
1941 ms |
18052 KB |
Correct. |
5 |
Execution timed out |
3060 ms |
159724 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3030 ms |
64460 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |