Submission #82476

#TimeUsernameProblemLanguageResultExecution timeMemory
82476nampsCommuter Pass (JOI18_commuter_pass)C++14
0 / 100
67 ms2112 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...