제출 #649757

#제출 시각아이디문제언어결과실행 시간메모리
649757RealSnakeCommuter Pass (JOI18_commuter_pass)C++17
24 / 100
55 ms7384 KiB
#include "bits/stdc++.h" #define ll long long using namespace std; int n, m, s, t, u, v; int a[100005]; ll dist[305][305]; vector<pair<int, ll>> node[100005]; ll ans; signed main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> m >> s >> t >> u >> v; for(int i = 1; i <= n; i++) { for(int j = 1; j <= n; j++) dist[i][j] = 1e18; dist[i][i] = 0; } for(int i = 0; i < m; i++) { int a, b; ll c; cin >> a >> b >> c; node[a].push_back({b, c}); node[b].push_back({a, c}); dist[a][b] = dist[b][a] = c; } for(int k = 1; k <= n; k++) { for(int i = 1; i <= n; i++) { for(int j = 1; j <= n; j++) { if(dist[i][k] + dist[k][j] < dist[i][j]) dist[i][j] = dist[i][k] + dist[k][j]; } } } ans = dist[u][v]; for(int i = 1; i <= n; i++) { for(int j = 1; j <= n; j++) { if(dist[s][i] + dist[i][j] + dist[j][t] == dist[s][t] || dist[s][j] + dist[j][i] + dist[i][t] == dist[s][t]) ans = min(ans, dist[u][i] + dist[j][v]); } } cout << ans; 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...