// Single-source shortest path. The final answer should be the maximum value from the starting point to the shortest path of other nodes. <Br/> # include <iostream> <br/> # include <queue> <br/> using namespace STD; <br/> const int INF = 50000000; <br/> int G [105] [105]; <br/> bool flag [105]; <br/> int dis [105]; <br/> int N; <br/> int Dijkstra (INT st) <br/>{< br/> int res = inf * (-1); <br/> for (INT I = 0; I <n; I ++) dis [I] = (I = sT? 0: INF); // initialization <br/> memset (flag, 0, sizeof (FLAG); </P> <p> for (INT I = 0; I <n; I ++) <br/>{< br/> int X, _ min = inf; <br/> for (INT y = 0; y <N; + + Y) <br/>{< br/> If (! Flag [y] & dis [y] <_ min) // find the minimum value in the unlabeled node <br/> _ min = dis [x = y]; <br/>}< br/> flag [x] = 1; // label <br/> for (INT y = 0; y <n; ++ y) <br/> {<br/> dis [y] = min (DIS [Y], DIS [x] + G [x] [Y]); // perform the relaxation operation on all other points starting from the label node <br/>}< br/> for (INT I = ST + 1; I <N; ++ I) <br/> If (DIS [I]> res) <br/> res = dis [I]; // find the maximum value in the single-source shortest path <br/> return res; <br/>}< br/> int main () <br/>{< br/> freopen ("in.txt", "r", stdin); <br/> char d [100]; <br /> Scanf ("% d", & N); <br/> memset (G, 0, sizeof (g); <br/> for (INT I = 1; I <n; ++ I) <br/> {<br/> for (Int J = 0; j <I; j ++) <br/>{< br/> scanf ("% s", d); <br/> If (d [0]! = 'X') <br/>{< br/> G [I] [J] = atoi (d ); <br/> G [J] [I] = atoi (d ); // use the atoi function to convert char * to int <br/>}< br/> else <br/>{< br/> G [I] [J] = inf; <br/> G [J] [I] = inf; <br/>}< br/> printf ("% d/N", Dijkstra (0 )); <br/> return 0; <br/>}