#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<double, pair<int, int>>;
const ll M = 1000000000000000000;
const double epsilon = 0.00000001;
double solve(int n, int m, int k, int h, vector<int> x,
vector<int> y, vector<int> c, vector<int> arr) {
double d[n]; d[0] = 0;
for(int l = 1; l < n; l++) d[l] = M;
vector<pair<int, int>> adj[n];
for(int l = 0; l < m; l++) {
adj[x[l]].push_back({y[l], c[l]});
adj[y[l]].push_back({x[l], c[l]});
}
priority_queue<pi, vector<pi>, greater<pi>> pq;
pq.push({0, {k, 0}});
while(!pq.empty()) {
double w = pq.top().first;
int u = pq.top().second.second;
int t = pq.top().second.first; pq.pop();
for(auto v : adj[u]) {
double D = w + v.second;
if(arr[v.first] == 0) D = 0;
if(d[v.first] > D) {
d[v.first] = D;
if(v.first != h) pq.push({d[v.first], {t, v.first}});
}
if(arr[v.first] == 2) {
while(t > 0 && fabs(D) > epsilon) D /= 2.0, t--;
if(d[v.first] > D) {
d[v.first] = D;
if(v.first != h) pq.push({d[v.first], {t, v.first}});
}
}
}
}
if(d[h] == M) return -1;
return d[h];
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
17 ms |
468 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
464 KB |
Correct. |
2 |
Correct |
26 ms |
416 KB |
Correct. |
3 |
Correct |
31 ms |
420 KB |
Correct. |
4 |
Correct |
27 ms |
340 KB |
Correct. |
5 |
Correct |
25 ms |
468 KB |
Correct. |
6 |
Correct |
22 ms |
1244 KB |
Correct. |
7 |
Correct |
34 ms |
1436 KB |
Correct. |
8 |
Correct |
12 ms |
2272 KB |
Correct. |
9 |
Correct |
23 ms |
468 KB |
Correct. |
10 |
Correct |
28 ms |
356 KB |
Correct. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
412 KB |
Correct. |
2 |
Correct |
27 ms |
424 KB |
Correct. |
3 |
Correct |
26 ms |
468 KB |
Correct. |
4 |
Correct |
28 ms |
340 KB |
Correct. |
5 |
Correct |
25 ms |
340 KB |
Correct. |
6 |
Correct |
6 ms |
1108 KB |
Correct. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
28 ms |
5704 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
476 KB |
Correct. |
2 |
Correct |
25 ms |
428 KB |
Correct. |
3 |
Correct |
24 ms |
400 KB |
Correct. |
4 |
Correct |
22 ms |
1204 KB |
Correct. |
5 |
Correct |
19 ms |
352 KB |
Correct. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
432 KB |
Correct. |
2 |
Correct |
22 ms |
424 KB |
Correct. |
3 |
Correct |
38 ms |
7768 KB |
Correct. |
4 |
Correct |
15 ms |
1108 KB |
Correct. |
5 |
Correct |
25 ms |
340 KB |
Correct. |
6 |
Correct |
27 ms |
456 KB |
Correct. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
28 ms |
340 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
42 ms |
388 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |