이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// from duckindog wth depression
#include<bits/stdc++.h>
using namespace std;
#define int long long
using pii = pair<int, int>;
const int N = 1e5 + 10;
int n, m;
int s, t, u, v;
vector<pair<int, int>> ad[N];
int f[N], sv[N], trace[N];
void sktra(int x) {
memset(f, 63, sizeof f);
priority_queue<pii, vector<pii>, greater<pii>> q;
q.emplace(f[x] = 0, x);
while (q.size()) {
int dis, u; tie(dis, u) = q.top(); q.pop();
if (dis != f[u]) continue;
for (auto duck : ad[u]) {
int v, w; tie(v, w) = duck;
if (f[v] > dis + w)
q.emplace(f[v] = dis + w, v);
}
}
}
vector<int> node;
bool dd[N];
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
if (fopen("duck.inp", "r")) {
freopen("duck.inp", "r", stdin);
freopen("duck.out", "w", stdout);
}
cin >> n >> m;
cin >> s >> t >> u >> v;
for (int i = 1; i <= m; ++i) {
int a, b, c; cin >> a >> b >> c;
ad[a].push_back({b, c});
ad[b].push_back({a, c});
}
if (s == u) {
sktra(s);
for (int i = 1; i <= n; ++i) sv[i] = f[i];
sktra(t);
for (int i = 1; i <= n; ++i) {
if (sv[i] + f[i] == f[s]) {
node.push_back(i);
dd[i] = 1;
}
}
sktra(v);
int dv = dd[v] ? 0 : 1e14;
for (auto x : node) dv = min(dv, f[x]);
cout << dv << '\n';
return 0;
}
}
컴파일 시 표준 에러 (stderr) 메시지
commuter_pass.cpp: In function 'int32_t main()':
commuter_pass.cpp:35:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
35 | freopen("duck.inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
commuter_pass.cpp:36:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
36 | freopen("duck.out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |