Submission #547565

#TimeUsernameProblemLanguageResultExecution timeMemory
547565tmn2005Commuter Pass (JOI18_commuter_pass)C++17
24 / 100
40 ms1876 KiB
#include<bits/stdc++.h> using namespace std; #define int long long const int N = 305; int dis[N][N]; signed main(){ ios::sync_with_stdio(0), cin.tie(0); int n, m, s, f, l, r; cin>>n>>m; cin>>s>>f; cin>>l>>r; memset(dis, 63, sizeof dis); for(int i=1; i<=n; i++)dis[i][i] = 0; while(m--){ int x, y, z; cin>>x>>y>>z; dis[x][y] = min(dis[x][y], z); dis[y][x] = min(dis[y][x], z); } for(int k=1; k<=n; k++){ for(int i=1; i<=n; i++){ for(int j=1; j<=n; j++){ dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]); } } } int res = dis[l][r]; for(int i=1; i<=n; i++){ for(int j=1; j<=n; j++){ if(dis[s][i] + dis[i][j] + dis[j][f] == dis[s][f]){ res = min(res, dis[l][i] + dis[j][r]); res = min(res, dis[l][j] + dis[i][r]); } } } 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...