#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template<class T>
using ordered_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define ft first
#define sc second
const int mod=1e9+7,INF=1e17,N=305;
int a[N][N];
main(){
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int n,m;
cin >> n >> m;
int s,t,u,v;
cin >> s >> t >> u >> v;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(i!=j){
a[i][j]=INF;
}
}
}
for(int i=0;i<m;i++){
int x,y,c;
cin >> x >> y >> c;
a[x][y]=min(a[x][y],c);
a[y][x]=min(a[y][x],c);
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
for(int k=1;k<=n;k++){
a[j][k]=min(a[j][k],a[j][i]+a[i][k]);
}
}
}
int ans=a[u][v];
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(a[s][i]+a[i][j]+a[j][t]==a[s][t]){
ans=min(ans,a[u][i]+a[j][v]);
ans=min(ans,a[u][j]+a[i][v]);
}
}
}
cout << ans;
}
Compilation message
commuter_pass.cpp:14:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
14 | main(){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
1876 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
1876 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
980 KB |
Output is correct |
2 |
Correct |
35 ms |
1020 KB |
Output is correct |
3 |
Correct |
29 ms |
980 KB |
Output is correct |
4 |
Correct |
38 ms |
980 KB |
Output is correct |
5 |
Correct |
46 ms |
1020 KB |
Output is correct |
6 |
Correct |
28 ms |
980 KB |
Output is correct |
7 |
Correct |
33 ms |
1028 KB |
Output is correct |
8 |
Correct |
42 ms |
980 KB |
Output is correct |
9 |
Correct |
41 ms |
1024 KB |
Output is correct |
10 |
Correct |
33 ms |
1020 KB |
Output is correct |
11 |
Correct |
27 ms |
980 KB |
Output is correct |
12 |
Correct |
32 ms |
1044 KB |
Output is correct |
13 |
Correct |
29 ms |
1040 KB |
Output is correct |
14 |
Correct |
28 ms |
980 KB |
Output is correct |
15 |
Correct |
35 ms |
1100 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
1876 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |