Submission #535127

#TimeUsernameProblemLanguageResultExecution timeMemory
535127amunduzbaevCommuter Pass (JOI18_commuter_pass)C++17
0 / 100
40 ms1888 KiB
#include "bits/stdc++.h" using namespace std; #define ar array #define int long long const int N = 305; int d[N][N]; signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n, m; cin>>n>>m; int s, t, u, v; cin>>s>>t>>u>>v; memset(d, 63, sizeof d); for(int i=1;i<=n;i++) d[i][i] = 0; for(int i=0;i<m;i++){ int a, b, c; cin>>a>>b>>c; d[a][b] = min(d[a][b], c); d[b][a] = min(d[b][a], c); } for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ for(int k=1;k<=n;k++){ d[i][j] = min(d[i][j], d[i][k] + d[k][j]); } } } int res = d[u][v]; //~ cout<<d[s][1]<<" "<<d[1][1]<<" "<<d[1][t]<<"\n"; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(d[s][i] + d[i][j] + d[j][t] == d[s][t]){ res = min(res, d[u][i] + d[j][v]); res = min(res, d[u][j] + d[i][v]); } } } cout<<res<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...