# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
897168 | duckindog | Commuter Pass (JOI18_commuter_pass) | C++14 | 32 ms | 1884 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// from duckindog wth depression
#include<bits/stdc++.h>
using namespace std;
#define int long long
using pii = pair<int, int>;
using T = tuple<int, int, int>;
const int N = 300 + 10;
int n, m;
int s, t, u, v;
int f[N][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 <= n; ++i) for (int j = 1; j <= n; ++j) f[i][j] = 1e14;
for (int i = 1; i <= n; ++i) f[i][i] = 0;
for (int i = 1; i <= m; ++i) {
int a, b, c; cin >> a >> b >> c;
f[a][b] = min(f[a][b], c);
f[b][a] = min(f[b][a], c);
}
for (int t = 1; t <= n; ++t)
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n; ++j) f[i][j] = min(f[i][j], f[i][t] + f[t][j]);
int answer = f[u][v];
for (int x = 1; x <= n; ++x) for (int y = 1; y <= n; ++y) {
if (f[s][x] + f[x][y] + f[y][t] != f[s][t]) continue;
answer = min({answer, f[u][x] + f[y][v], f[u][y] + f[x][v]});
}
cout << answer << '\n';
}
Compilation message (stderr)
# | 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... |