#include<bits/stdc++.h>
using namespace std ;
#define maxn 309
#define ll long long
#define pb push_back
#define fi first
#define se second
#define left id<<1
#define right id<<1|1
#define re exit(0);
#define _lower(x) lower_bound(v.begin(),v.end(),x)-v.begin()+1
#define TIME ( 1.0*clock() / CLOCKS_PER_SEC )
#define CEIL(a,b) (a/b + (a%b!=0))
const int mod = 1e9+7 ;
const int INF = 1e9 ;
typedef vector<int> vi ;
typedef pair<int,int> pii ;
typedef vector<pii> vii ;
template < typename T > void chkmin ( T &a , T b ) { if ( a > b ) a = b ; }
template < typename T > void chkmax ( T &a , T b ) { if ( a < b ) a = b ; }
void add ( int &a , int b )
{
a += b ;
if ( a >= mod ) a -= mod ;
if ( a < 0 ) a += mod ;
}
void rf ()
{
#ifndef ONLINE_JUDGE
freopen("bai1.inp","r",stdin);
freopen ("bai1.out","w",stdout) ;
#endif
}
int _pow ( int a , int n )
{
if ( n == 0 ) return 1 ;
int res = _pow (a,n/2) ;
if ( n % 2 ) return 1ll*res*res%mod*a%mod ;
else return 1ll*res*res%mod ;
}
int n ,m ;
vi adjList [maxn] ;
int S,T,U,V ;
ll d [maxn][maxn] ;
int main ()
{
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
rf () ;
cin >> n >> m ;
cin >> S >> T >> U >> V ;
memset (d,0x3f,sizeof d) ;
for ( int i = 1 ; i <= n ; i ++ ) d[i][i] = 0 ;
for ( int i = 1 ; i <= m ; i ++ )
{
int u , v , w ; cin >> u >> v >> w ;
chkmin (d[u][v],1ll*w) ;
chkmin (d[v][u],1ll*w) ;
}
for ( int k = 1 ; k <= n ; k ++ )
{
for ( int i = 1 ; i <= n ; i ++ )
{
for ( int j = 1 ; j <= n ; j ++ )
{
chkmin (d[i][j],d[i][k]+d[k][j]) ;
}
}
}
ll res = d[U][V] ;
for ( int c1 = 1 ; c1 <= n ; c1 ++ ) for ( int c2 = 1 ; c2 <= n ; c2 ++ )
{
if ( d[S][c1] + d[c1][c2] + d[c2][T] == d[S][T] )
{
chkmin (res,min(d[c1][U]+d[c2][V],d[c1][V]+d[c2][U])) ;
}
}
cout << res ;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
commuter_pass.cpp: In function 'void rf()':
commuter_pass.cpp:34:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
34 | freopen("bai1.inp","r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
commuter_pass.cpp:35:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
35 | freopen ("bai1.out","w",stdout) ;
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |