Submission #547559

#TimeUsernameProblemLanguageResultExecution timeMemory
547559tmn2005Commuter Pass (JOI18_commuter_pass)C++17
0 / 100
42 ms4496 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define NeedForSpeed ios::sync_with_stdio(0), cin.tie(0) const int N = 1e5 + 12, INF = 1e18; int n, m, s, f, l, r, x, y, z, res, dis[505][505]; void solve(){ 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] = z; dis[y][x] = z; } for(int i=1; i<=n; i++){ for(int j=1; j<=n; j++){ for(int k=1; k<=n; k++){ 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[r][i] + dis[j][l]); } } } cout<<res<<"\n"; } main(){ NeedForSpeed; int T = 1; // cin >> T; while(T--){ solve(); } return 0; }

Compilation message (stderr)

commuter_pass.cpp:40:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   40 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...