#include <cstdio> #include <cstdlib> int main() { int n; while (scanf("%d", &n) == 1) { int dis[101][101] = {}; for (int a = 2; a <= n; a++) { for (int b = 1; b < a; b++) { char s[99]; scanf("%s", s); dis[a][b] = dis[b][a] = (s[0] == 'x' ? 1e9 : atoi(s)); } } for (int k = 1; k <= n; k++) { for (int a = 1; a <= n; a++) { for (int b = 1; b <= n; b++) { if (dis[a][k] + dis[k][b] < dis[a][b]) { dis[a][b] = dis[a][k] + dis[k][b]; } } } } int ans = 0; for (int b = 1; b <= n; b++) { ans = dis[1][b] > ans ? dis[1][b] : ans; } printf("%d\n", ans); } return 0; }
Hello, I am a CS student from Taiwan.
I am learing English and Programming.
I'll save source code of some problems or small programs without comments in this blog.
I would recommend you not to read solution from others before you solved the problem.
(這邊專門存放沒有任何註解的小程式/OJ題目程式碼)
2013年8月18日
UVa 423 - MPI Maelstrom
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言