#include "cyberland.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using node = pair<ll, ll>;
vector<vector<node>> g;
void dfs(int u, int p, vector<int>& res){
if(u == p) return;
res[u] = 1;
for(auto [v, w]: g[u])
if(!res[v])
dfs(v, p, res);
}
double solve(int N, int M, int K, int H, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) {
// for(int x: arr) assert(x < 2);
g.assign(N, vector<node>());
vector<ll> h(N, 1e18);
for(int i = 0; i < M; ++i){
g[x[i]].emplace_back(y[i], c[i]);
g[y[i]].emplace_back(x[i], c[i]);
}
vector<int> up(N), to(N);
dfs(0, H, up);
dfs(H, 0, to);
priority_queue<node, vector<node>, greater<node>> b;
for(int i = 0; i < N; ++i)
if(up[i] & to[i])
b.emplace(0, i);
while(!b.empty()){
auto [cur, u] = b.top();
b.pop();
if(h[u] <= cur) continue;
h[u] = cur;
for(auto [v, w]: g[u])
b.emplace(cur+w, v);
}
return (h[H] == 1e18 ? -1 : h[H]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
15 ms |
600 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
22 ms |
600 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
26 ms |
600 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
29 ms |
9948 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
22 ms |
604 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
32 ms |
856 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
25 ms |
604 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
25 ms |
600 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |