#include <iostream>
#include <vector>
#include <queue>
#include <iomanip>
using namespace std;
vector<pair<int, int>> g[100005];
double f[100005][35];
double solve(int n, int m, int k, int h, vector<int> x, vector<int> y, vector<int> c, vector<int> a) {
vector<int> v, vv;
for (int i = 0; i < n; i++) g[i].clear();
for (int i = 0; i < n; i++) {
if (a[i] == 0) v.push_back(i);
if (a[i] == 2) vv.push_back(i);
for (int j = 0; j <= k; j++) {
f[i][j] = 1e18;
}
}
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 w : v) f[w][0] = 0;
f[0][0] = 0;
for (int i = 0; i <= k; i++) {
priority_queue<pair<double, int>> q;
for (int j = 0; j < n; j++) {
if (j == h) continue;
q.push({-f[j][i], j});
}
while (!q.empty()) {
double x = -q.top().first;
int u = q.top().second;
q.pop();
if (f[u][i] != x || u == h) continue;
//cout << u << " " << i << " " << x << '\n';
for (auto w : g[u]) {
if (f[w.first][i] > f[u][i] + w.second) {
f[w.first][i] = f[u][i] + w.second;
q.push({-f[w.first][i], w.first});
}
}
}
if (i == k) break;
for (int j = 0; j < n; j++) {
if (j == h) continue;
if (a[j] <= 1) f[j][i + 1] = f[j][i];
else if (a[j] == 2) f[j][i + 1] = f[j][i] / 2;
}
}
double res = 1e18;
for (int j = 0; j <= k; j++) {
res = min(res, f[h][j]);
}
if (res > 1e17) return -1;
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
35 ms |
3152 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
84 ms |
3912 KB |
Correct. |
2 |
Correct |
107 ms |
4424 KB |
Correct. |
3 |
Correct |
93 ms |
4032 KB |
Correct. |
4 |
Correct |
115 ms |
3400 KB |
Correct. |
5 |
Correct |
130 ms |
3912 KB |
Correct. |
6 |
Correct |
213 ms |
7424 KB |
Correct. |
7 |
Correct |
287 ms |
8896 KB |
Correct. |
8 |
Correct |
135 ms |
12264 KB |
Correct. |
9 |
Correct |
78 ms |
4136 KB |
Correct. |
10 |
Correct |
99 ms |
4032 KB |
Correct. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
118 ms |
6240 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
644 ms |
26716 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
91 ms |
6424 KB |
Correct. |
2 |
Correct |
102 ms |
6476 KB |
Correct. |
3 |
Correct |
96 ms |
6476 KB |
Correct. |
4 |
Correct |
182 ms |
9308 KB |
Correct. |
5 |
Correct |
72 ms |
4176 KB |
Correct. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
134 ms |
6480 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
139 ms |
6472 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3078 ms |
9676 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |