제출 #82471

#제출 시각아이디문제언어결과실행 시간메모리
82471hatuank97lhpCommuter Pass (JOI18_commuter_pass)C++17
0 / 100
10 ms2064 KiB
#include <bits/stdc++.h> #define LL long long using namespace std; LL n,m,A,B,C,D,a[305][305], res, oo = 1e15; int main() { //freopen(".inp","r",stdin); cin >> n >> m >> A >> B >> C >> D; for(int i = 1; i <= n; ++ i) { for(int j = 1; j <= m; ++ j) if( i != j ) a[i][j] = oo; } LL u,v,w; for(int i = 1; i <= m ;++ i) { cin >> u >> v >> w; a[u][v] = a[v][u] = min( a[u][v], w ); } for(int u = 1; u <= n; ++ u) { for(int i = 1; i <= n; ++ i) { for(int j = 1; j <= n; ++ j) a[i][j] = min( a[i][u] + a[u][j], a[i][j] ); } } res = oo; for(int i = 1; i <= n; ++ i) { for(int j = 1; j <= n; ++ j) { if( a[A][i] + a[i][j] + a[j][B] == a[A][B] ) { res= min( res, a[C][i] + a[j][D] ); } } } cout << res; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...