Submission #547564

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