#include <bits/stdc++.h>
using namespace std;
/*
*/
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long double, long double> pdd;
const int MAXN = 1e5+10, MAXK = 30+15;
const long long BIG = 1e18+8;
const long double PRECISION = 1e-7;
vector<pii> e[MAXN];
long double ds[MAXN][MAXK];
double solve(int n, int m, int k, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr){
for (int i=0;i<n;i++){
e[i].clear();
for (int j=0;j<=k;j++) ds[i][j]=BIG;
}
for (int i=0;i<m;i++){
int a = x[i], b = y[i];
e[a].emplace_back(b, c[i]);
e[b].emplace_back(a,c[i]);
}
typedef tuple<long double, int, int> node; // {dst, qntk, u}
priority_queue<node, vector<node>, greater<>> q;
for (int i=0;i<n;i++) if (!i || arr[i]==0){
ds[i][0] = 0;
q.emplace(0, 0, i);
}
while (!q.empty()){
auto [d, qk, u] = q.top();
q.pop();
if (ds[u][qk] != d) continue;
if (u == H) continue;
for (auto &[i, cs]:e[u]){
long double nc = d+cs;
// sem usar
if (ds[i][qk]>nc){
ds[i][qk] = nc;
q.emplace(nc, qk, i);
}
// usando
if (qk<k && arr[u] == 2 && ds[i][qk+1]> (d/2.000+cs)){
ds[i][qk+1] = d/2.00 + cs;
q.emplace(ds[i][qk+1], qk+1, i);
}
}
}
long double ans = BIG;
for (int i=0;i<=k;i++) ans = min(ans, ds[H][i]);
if (ans == BIG) return -1;
return ans;
}
// signed main(){
// ios_base::sync_with_stdio(false);
// cin.tie(nullptr);
// cout << solve(3, 2, 30, 2, {1, 2}, {2, 0}, {12, 4}, {1, 2, 1}) << '\n';
// cout << solve(4, 4, 30, 3, {0, 0, 1, 2}, {1, 2, 3, 3}, {5, 4, 2, 4}, {1, 0, 2, 1}) << '\n';
// return 0;
// }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
3676 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
6472 KB |
Correct. |
2 |
Correct |
32 ms |
6736 KB |
Correct. |
3 |
Correct |
32 ms |
6564 KB |
Correct. |
4 |
Correct |
30 ms |
5716 KB |
Correct. |
5 |
Correct |
30 ms |
6524 KB |
Correct. |
6 |
Correct |
28 ms |
13300 KB |
Correct. |
7 |
Correct |
35 ms |
13404 KB |
Correct. |
8 |
Correct |
17 ms |
19792 KB |
Correct. |
9 |
Correct |
27 ms |
4192 KB |
Correct. |
10 |
Correct |
28 ms |
4176 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
32 ms |
6704 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1578 ms |
65700 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
6648 KB |
Correct. |
2 |
Correct |
31 ms |
6712 KB |
Correct. |
3 |
Correct |
28 ms |
6736 KB |
Correct. |
4 |
Correct |
28 ms |
13552 KB |
Correct. |
5 |
Correct |
30 ms |
4176 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
31 ms |
6736 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
569 ms |
8460 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3046 ms |
17844 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |