제출 #82474

#제출 시각아이디문제언어결과실행 시간메모리
82474rafataCommuter Pass (JOI18_commuter_pass)C++14
0 / 100
68 ms4484 KiB
#include <bits/stdc++.h> using namespace std; const long long oo=1e18; const int N=500; long long c[N][N]; int n,m,a,b,s,t; int main() { //freopen("i.inp","r",stdin); cin>>n>>m>>a>>b>>s>>t; for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) if(i!=j) c[i][j]=oo; for(int i=1;i<=m;i++) { int u,v,w; cin>>u>>v>>w; c[u][v]=c[v][u]=w; } for(int k=1;k<=n;k++) for(int u=1;u<=n;u++) for(int v=1;v<=n;v++) if(c[u][k] && c[k][v]) c[u][v]=min(c[u][v],c[u][k]+c[k][v]); long long ans=oo; for(int x=1;x<=n;x++) for(int y=1;y<=n;y++) if(c[a][x] + c[x][y]+ c[y][b] ==c[a][b]) ans=min(ans,c[x][s]+c[y][t]); cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...