/* First obtain the shortest path from each point to 1 and then find the prototype of the maximum value from the Shortest Path: int atoi (const char * nptr). Function Description: The nptr parameter, if the first non-space character does not exist or is neither a number nor a plus or minus sign, 0 is returned. Otherwise, type conversion is started and non-numbers (including Terminator \ 0) are detected) the conversion is stopped. The return value is an integer. */# Include <stdio. h> # include <stdlib. h> # include <string. h> int map [110] [110], vis [110], DIST [110], n; char s [1000]; int Zhao () {int I, xia =-1; for (I = 1; I <= N; I ++) if (vis [I] = 0 & (Xia =-1 | Dist [I] <Dist [Xia]) Xia = I; return Xia ;} int Dijkstra () {int max = 0, I, j, Xia; memset (VIS, 0, sizeof (VIS); vis [1] = 1; for (I = 1; I <= N; I ++) Dist [I] = map [1] [I]; for (I = 2; I <= N; I ++) {Xia = Zhao (); vis [Xia] = 1; for (j = 1; j <= N; j ++) if (vis [J] = 0 & Dist [J]> Dist [Xia] + map [Xia] [J]) dist [J] = DIST [Xia] + map [Xia] [J];} for (I = 2; I <= N; I ++) if (Dist [I]> MAX) max = DIST [I]; return Max;} int main () {int I, j, k; scanf ("% d ", & N); getchar (); for (I = 2; I <= N; I ++) {gets (s); j = 1; k = 0; while (s [k]) {If (s [k] = 'X') {map [I] [J ++] = 999999999; k = K + 2; continue;} map [I] [J ++] = atoi (S + k ); while (s [k]> = '0' & S [k] <= '9') K ++; while (s [k] = '') k ++ ;}}for (I = 1; I <= N; I ++) {for (j = I; j <= N; j ++) if (I = J) map [I] [I] = 0; else map [I] [J] = map [J] [I];} printf ("% d \ n", Dijkstra (); Return 0 ;}