이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "cyberland.h"
using namespace std;
using pid = pair<int, double>;
using tp = tuple<double, int, int, int>;
const int N = 1e5 + 5, K = 75;
const double C = 1e11;
double d[N][K][2], ans;
vector<pid> v[N];
bool f[N][K][2];
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) {
k = min(k, 67), ans = DBL_MAX;
priority_queue<tp, vector<tp>, greater<tp>> q;
for (int i = 0; i <= n; i++) v[i].clear();
for (int i = 0; i < m; i++) v[x[i]].emplace_back(y[i], c[i]), v[y[i]].emplace_back(x[i], c[i]);
for (int i = 0; i <= n; i++) for (int j = 0; j <= k; j++) d[i][j][0] = d[i][j][1] = DBL_MAX, f[i][j][0] = f[i][j][1] = 0;
q.emplace(d[h][0][0] = 0, h, 0, 0);
while (!q.empty()) {
auto [nd, nn, nsa, nsb] = q.top(); q.pop();
if (f[nn][nsa][nsb]) continue; f[nn][nsa][nsb] = 1;
for (auto &[tn, td]: v[nn]) {
double nds = nd + (nsb ? 0 : td / pow((double) 2, nsa));
if (d[tn][nsa][nsb] > nds) q.emplace(d[tn][nsa][nsb] = nds, tn, nsa, nsb);
}
if (!arr[nn]) for (auto &[tn, td]: v[nn]) if (d[tn][nsa][!nsb] > nd) q.emplace(d[tn][nsa][!nsb] = nd, tn, nsa, !nsb);
if (nsa < k && arr[nn] == 2) {
for (auto &[tn, td]: v[nn]) {
double nds = nd + (nsb ? 0 : td / pow((double) 2, nsa + 1));
if (d[tn][nsa][nsb] > nds) q.emplace(d[tn][nsa][nsb] = nds, tn, nsa + 1, nsb);
}
}
}
for (int i = 0; i <= k; i++) for (int j = 0; j < 2; j++) ans = min(ans, d[0][i][j]);
return (ans == DBL_MAX ? -1 : 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:23:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
23 | if (f[nn][nsa][nsb]) continue; f[nn][nsa][nsb] = 1;
| ^~
cyberland.cpp:23:40: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
23 | if (f[nn][nsa][nsb]) continue; f[nn][nsa][nsb] = 1;
| ^
# | 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... |