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;
long long n,m,s,t,u,v;
long long l,r,h;
long long kq;
long long dp[305][305];
int main()
{
// freopen("vao.inp","r",stdin);
cin>>n>>m;
cin>>s>>t;
cin>>u>>v;
for (long long i=1;i<=n;i++)
for (long long j=1;j<=n;j++) dp[i][j]=10000000000000000;
for (long long i=1;i<=n;i++) dp[i][i]=0;
while (m--)
{
cin>>l>>r>>h;
dp[l][r]=min(dp[l][r],h);
dp[r][l]=dp[l][r];
}
for (long long k=1;k<=n;k++)
for (long long i=1;i<=n;i++)
for (long long j=1;j<=n;j++)
{
dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
}
kq=10000000000000000;
for (long long i=1;i<=n;i++)
for (long long j=1;j<=n;j++)
{
if (dp[s][t]==dp[s][i]+dp[i][j]+dp[j][t])
{
kq=min(kq,dp[i][u]+dp[j][v]);
}
}
cout<<kq;
return 0;
}
# | 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... |