제출 #1053689

#제출 시각아이디문제언어결과실행 시간메모리
1053689tht2005Commuter Pass (JOI18_commuter_pass)C++17
0 / 100
17 ms2060 KiB
#include <bits/stdc++.h> #define fi first #define se second #define int long long using namespace std; const int MAXN = 303; typedef pair<int, int> II; int n, m, s, t, u, v; long long d[MAXN][MAXN]; int32_t main() { ios::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m >> s >> t >> u >> v; memset(d, 0x3f, sizeof(d)); for (int i = 1; i <= m; ++i) { int a, b, c; cin >> a >> b >> c; d[a][b] = min(d[a][b], c); d[b][a] = min(d[b][a], c); } for(int k = 1; k <= n; ++k) for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) d[i][j] = d[i][k] + d[k][j]; long long ans = d[u][v]; for(int i = 1; i <= n; ++i) { if(d[s][i] + d[i][t] != d[s][t]) continue; for(int j = 1; j <= n; ++j) { if(d[s][i] + d[i][j] + d[j][t] != d[s][t]) continue; ans = min(ans, d[u][i] + d[j][v]); ans = min(ans, d[u][j] + d[i][v]); } } 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...