# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1013367 | daffuwu | Commuter Pass (JOI18_commuter_pass) | C++14 | 38 ms | 2652 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.
#include <bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
long long n, m, dst[369][369], s, t, u, v, a, b, c, ans;
int main()
{
long long i, j, ii;
scanf("%lld%lld%lld%lld%lld%lld", &n, &m, &s, &t, &u, &v);
for (i=1; i<=n; i++)
{
for (j=1; j<=n; j++)
{
if (i != j) dst[i][j] = 1e15;
}
}
for (i=1; i<=m; i++)
{
scanf("%lld%lld%lld", &a, &b, &c);
dst[a][b] = dst[b][a] = c;
}
for (ii=1; ii<=n; ii++)
{
for (i=1; i<=n; i++)
{
for (j=1; j<=n; j++) dst[i][j] = min(dst[i][j], dst[i][ii]+dst[ii][j]);
}
}
ans = dst[u][v];
for (i=1; i<=n; i++)
{
for (j=1; j<=n; j++)
{
if (min(dst[s][i]+dst[j][t], dst[s][j]+dst[i][t])+dst[i][j] == dst[s][t]) ans = min(ans, dst[u][i]+dst[j][v]);
}
}
printf("%lld\n", ans);
}
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... |