#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++)
{
long long u,v,w;
cin>>u>>v>>w;
c[u][v]=c[v][u]=min(c[u][v],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=c[s][t];
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]);
swap(a,b);
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
26 ms |
4344 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
28 ms |
4428 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
68 ms |
4428 KB |
Output is correct |
2 |
Correct |
63 ms |
4428 KB |
Output is correct |
3 |
Correct |
45 ms |
4428 KB |
Output is correct |
4 |
Correct |
88 ms |
4428 KB |
Output is correct |
5 |
Correct |
72 ms |
4428 KB |
Output is correct |
6 |
Correct |
45 ms |
4428 KB |
Output is correct |
7 |
Correct |
50 ms |
4428 KB |
Output is correct |
8 |
Correct |
49 ms |
4428 KB |
Output is correct |
9 |
Correct |
45 ms |
4428 KB |
Output is correct |
10 |
Correct |
68 ms |
4428 KB |
Output is correct |
11 |
Correct |
43 ms |
4428 KB |
Output is correct |
12 |
Correct |
46 ms |
4428 KB |
Output is correct |
13 |
Correct |
45 ms |
4428 KB |
Output is correct |
14 |
Correct |
44 ms |
4428 KB |
Output is correct |
15 |
Correct |
44 ms |
4428 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
26 ms |
4344 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |