#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<double>> dp;
vector<vector<pair<int, int>>> adjlist;
vector<int> type;
int maxk;
int target;
void recur(int node, int curk, double curw)
{
if (type[node] == 0)
curw = 0;
else if (type[node] == 2)
{
if (curw < dp[node][curk])
{
dp[node][curk] = curw;
if (node == target)
return;
for (auto a : adjlist[node])
recur(a.first, curk, curw + a.second);
}
curw /= 2;
curk++;
}
if (curk > maxk)
return;
if (curw < dp[node][curk])
{
dp[node][curk] = curw;
if (node == target)
return;
for (auto a : adjlist[node])
recur(a.first, curk, curw + a.second);
}
}
double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr)
{
K = 30;
maxk = K;
target = H;
type = arr;
dp.clear();
adjlist.clear();
adjlist.resize(N);
for (int i = 0; i < M; i++)
adjlist[x[i]].push_back({y[i], c[i]}), adjlist[y[i]].push_back({x[i], c[i]});
dp.resize(N);
for (auto &a : dp)
a.resize(K + 1, 1e15);
recur(0, 0, 0);
double mini = 1e15;
for (int i = 0; i <= K; i++)
mini = min(mini, dp[H][i]);
if (mini == 1e15)
return -1;
return mini;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
856 KB |
Correct. |
2 |
Correct |
15 ms |
860 KB |
Correct. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
1740 KB |
Correct. |
2 |
Correct |
20 ms |
1868 KB |
Correct. |
3 |
Correct |
21 ms |
1792 KB |
Correct. |
4 |
Correct |
20 ms |
1868 KB |
Correct. |
5 |
Correct |
21 ms |
1836 KB |
Correct. |
6 |
Correct |
19 ms |
4836 KB |
Correct. |
7 |
Correct |
23 ms |
4632 KB |
Correct. |
8 |
Correct |
12 ms |
8136 KB |
Correct. |
9 |
Correct |
21 ms |
1224 KB |
Correct. |
10 |
Correct |
20 ms |
1368 KB |
Correct. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
1736 KB |
Correct. |
2 |
Correct |
25 ms |
1676 KB |
Correct. |
3 |
Correct |
19 ms |
1768 KB |
Correct. |
4 |
Correct |
28 ms |
1272 KB |
Correct. |
5 |
Correct |
21 ms |
1372 KB |
Correct. |
6 |
Correct |
5 ms |
3416 KB |
Correct. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
94 ms |
23912 KB |
Correct. |
2 |
Correct |
109 ms |
1832 KB |
Correct. |
3 |
Correct |
94 ms |
1844 KB |
Correct. |
4 |
Correct |
98 ms |
1852 KB |
Correct. |
5 |
Correct |
96 ms |
1360 KB |
Correct. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
94 ms |
1648 KB |
Correct. |
2 |
Correct |
120 ms |
2252 KB |
Correct. |
3 |
Correct |
121 ms |
1676 KB |
Correct. |
4 |
Correct |
1315 ms |
4536 KB |
Correct. |
5 |
Correct |
30 ms |
1136 KB |
Correct. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
1772 KB |
Correct. |
2 |
Correct |
20 ms |
1596 KB |
Correct. |
3 |
Correct |
56 ms |
30036 KB |
Correct. |
4 |
Correct |
16 ms |
3536 KB |
Correct. |
5 |
Correct |
22 ms |
1400 KB |
Correct. |
6 |
Correct |
21 ms |
1816 KB |
Correct. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
199 ms |
1612 KB |
Correct. |
2 |
Correct |
40 ms |
1116 KB |
Correct. |
3 |
Incorrect |
2118 ms |
40300 KB |
Wrong Answer. |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
203 ms |
1756 KB |
Correct. |
2 |
Correct |
41 ms |
1372 KB |
Correct. |
3 |
Execution timed out |
3083 ms |
51876 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |