#include "cyberland.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
struct A {
int v, st;
double w;
bool operator < (const A& o) const {
return w > o.w;
}
};
vector<A> adj[100100];
priority_queue<A> pq;
double dis[31][100100];
double val[31];
bool vis[100100];
int n, m, k, e;
void dfs(int v) {
vis[v] = 1;
for (auto& x : adj[v]) {
if (!vis[x.v]) dfs(x.v);
}
}
double solve(int NN, int M, int K, int H, vector<int> X, vector<int> Y, vector <int> C, vector<int> a) {
n = NN, m = M, k = K, e = H;
for (int i = 0;i < m;i++) {
adj[X[i]].push_back({ Y[i], 0, (double)C[i] });
adj[Y[i]].push_back({ X[i], 0, (double)C[i] });
}
memset(vis, 0, sizeof vis);
dfs(0);
if (!vis[e]) {
for (int i = 0;i < n;i++) adj[i].clear();
return -1;
}
val[0] = 1;
for (int i = 1;i <= k;i++) val[i] = val[i - 1] * 2;
for (int i = 0;i <= k;i++) {
for (int j = 0;j < n;j++) dis[i][j] = 1e300;
}
for (int i = 0;i < n;i++) {
if (i != 0 && a[i] != 0) continue;
pq.push({ i, 0, 0 });
dis[0][i] = 0;
}
while (!pq.empty()) {
auto x = pq.top();
pq.pop();
int v = x.v, st = x.st;
if (x.w > dis[st][v]) continue;
if (v == e) continue;
for (auto& x : adj[v]) {
if (dis[st][x.v] > dis[st][v] + x.w * val[st]) {
dis[st][x.v] = dis[st][v] + x.w * val[st];
pq.push({ x.v, st, dis[st][x.v] });
}
if (a[x.v] == 2 && st < k) {
if (dis[st + 1][x.v] > dis[st][v] + x.w * val[st]) {
dis[st + 1][x.v] = dis[st][v] + x.w * val[st];
pq.push({ x.v, st + 1, dis[st + 1][x.v] });
}
}
}
}
for (int i = 0;i < n;i++) {
adj[i].clear();
}
double mn = 1e300;
for (int j = 0;j <= k;j++) {
if (dis[j][e] == 1e300) continue;
mn = min(mn, dis[j][e] / val[j]);
}
return mn;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
46 ms |
27240 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
27224 KB |
Correct. |
2 |
Correct |
24 ms |
27308 KB |
Correct. |
3 |
Correct |
24 ms |
27300 KB |
Correct. |
4 |
Correct |
29 ms |
27284 KB |
Correct. |
5 |
Correct |
29 ms |
27280 KB |
Correct. |
6 |
Correct |
21 ms |
27884 KB |
Correct. |
7 |
Correct |
29 ms |
27996 KB |
Correct. |
8 |
Correct |
17 ms |
28764 KB |
Correct. |
9 |
Correct |
29 ms |
27124 KB |
Correct. |
10 |
Correct |
23 ms |
26972 KB |
Correct. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
30 ms |
27384 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
425 ms |
33852 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
27224 KB |
Correct. |
2 |
Correct |
23 ms |
27288 KB |
Correct. |
3 |
Correct |
22 ms |
27228 KB |
Correct. |
4 |
Correct |
25 ms |
28508 KB |
Correct. |
5 |
Correct |
24 ms |
26972 KB |
Correct. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
22 ms |
27228 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
117 ms |
27292 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
27 ms |
54868 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |