mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:31:59 +00:00
P3905 道路重建
R53608296
This commit is contained in:
parent
a4a1d02e43
commit
04c6d341b6
34
Luogu/problem/P3905/P3905.cpp
Normal file
34
Luogu/problem/P3905/P3905.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int n, m, u, v, w, d, a, b, f[105][105], g[105][105];
|
||||
|
||||
int main() {
|
||||
cin >> n >> m;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = 1; j <= n; j++) {
|
||||
g[i][j] = f[i][j] = i == j ? 0 : 0x3f3f3f3f;
|
||||
}
|
||||
}
|
||||
for (int i = 1; i <= m; i++) {
|
||||
cin >> u >> v >> w;
|
||||
f[u][v] = f[v][u] = w;
|
||||
g[u][v] = g[v][u] = 0;
|
||||
}
|
||||
cin >> d;
|
||||
for (int i = 1; i <= d; i++) {
|
||||
cin >> u >> v;
|
||||
g[u][v] = g[v][u] = f[u][v];
|
||||
}
|
||||
for (int k = 1; k <= n; k++) {
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = 1; j <= n; j++) {
|
||||
g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
cin >> a >> b;
|
||||
cout << g[a][b] << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user