0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2025-01-11 21:51:59 +00:00

#11. 开会还是逛街

https://sjzezoj.com/submission/35071
This commit is contained in:
Baoshuo Ren 2021-09-23 21:20:30 +08:00 committed by Baoshuo Ren
parent 9617b48f6f
commit 59c44b511e
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

30
S2OJ/11/11.cpp Normal file
View 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;
}