이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> g[100005];
bool reach[100005];
void dfsreach(int u) {
if (reach[u])
return;
reach[u] = true;
for (auto v : g[u]) {
dfsreach(v.first);
}
}
long long dist[100005];
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 i = 0; i < M; i++) {
g[x[i]].push_back({y[i], c[i]});
g[y[i]].push_back({x[i], c[i]});
}
dfsreach(0);
priority_queue<pair<int, int>> pq;
for (int i = 0; i < N; i++) {
dist[i] = 2e18;
if (arr[i] == 0 && reach[i]) {
pq.push({0, i});
dist[i] = 0;
}
}
pq.push({0, 0});
dist[0] = 0;
while (!pq.empty()) {
auto cur = pq.top();
pq.pop();
for (auto nxt : g[cur.second]) {
if (dist[nxt.first] > -cur.first + nxt.second) {
dist[nxt.first] = -cur.first + nxt.second;
pq.push({-dist[nxt.first], nxt.first});
}
}
}
for (int i = 0; i < N; i++) {
g[i].clear();
reach[i] = false;
}
if (dist[H] > 1e18)
return -1;
else
return dist[H];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |