mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2025-01-11 18:31:58 +00:00
parent
9617b48f6f
commit
59c44b511e
30
S2OJ/11/11.cpp
Normal file
30
S2OJ/11/11.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int n, m, x, u, v, w, g[1005][1005], ans;
|
||||
|
||||
int main() {
|
||||
cin >> n >> m >> x;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = 1; j <= n; j++) {
|
||||
g[i][j] = i == j ? 0 : 0x3f3f3f3f;
|
||||
}
|
||||
}
|
||||
for (int i = 1; i <= m; i++) {
|
||||
cin >> u >> v >> w;
|
||||
g[u][v] = min(g[u][v], w);
|
||||
}
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 1; i <= n; i++) {
|
||||
ans = max(ans, g[i][x] + g[x][i]);
|
||||
}
|
||||
cout << ans << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user