이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cyberland.h"
#include <bits/stdc++.h>
#define pii pair<ll, ll>
typedef long long ll;
using namespace std;
const int MAX = 100007;
vector<pii> G[MAX];
bool V[MAX];
ll D[MAX], LD[MAX];
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 < N; ++i) G[i].clear();
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]);
}
memset(V, 0, sizeof(V));
V[0] = 1;
queue<int> Q;
Q.push(0);
while (!Q.empty()) {
int cur = Q.front(); Q.pop();
for (auto [next, _] : G[cur]) {
if (V[next]) continue;
V[next] = 1;
Q.push(next);
}
}
if (!V[H]) return -1;
memset(D, 0x3f, sizeof(D));
priority_queue<pii, vector<pii>, greater<pii>> PQ;
for (int i = 0; i < N; ++i) {
if (i && arr[i]) continue;
PQ.emplace(D[i] = 0, i);
}
while (!PQ.empty()) {
auto [cd, cur] = PQ.top(); PQ.pop();
if (cd > D[cur]) continue;
for (auto [next, nd] : G[cur]) {
if (D[next] <= cd + nd) continue;
PQ.emplace(D[next] = cd + nd, next);
}
}
memset(LD, 0x3f, sizeof(LD));
PQ.emplace(LD[H] = 0, H);
while (!PQ.empty()) {
auto [cd, cur] = PQ.top(); PQ.pop();
if (cd > LD[cur]) continue;
for (auto [next, nd] : G[cur]) {
if (LD[next] <= cd + nd) continue;
PQ.emplace(LD[next] = cd + nd, next);
}
}
double ans = D[H];
if (K) {
for (int i = 0; i < N; ++i) {
if (arr[i] != 2 || !V[i]) continue;
ll a = D[i], b = LD[i], c = 1e18;
for (auto [next, nd] : G[i]) c = min(c, nd);
double cd = (double)a / 2.0;
for (int k = 1; k < min(100, K); ++k) {
cd = (cd + 2LL * c) / 2.0;
}
ans = min(ans, cd);
}
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:65:17: warning: unused variable 'b' [-Wunused-variable]
65 | ll a = D[i], b = LD[i], c = 1e18;
| ^
# | 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... |