Title Link:http://poj.org/problem?id=1502
Test instructions: What is the minimum time required to request from processor 1 to other processors;
The input is the lower triangle, if x means a "I" "J" cannot be contacted directly;
#include <cstdio>#include<cstring>#include<cstdlib>#include<iostream>#include<algorithm>using namespacestd;#defineN 110#defineINF 0XFFFFFFFintMaps[n][n], N;voidFloyd () { for(intk=1; k<=n; k++) for(intI=1; i<=n; i++) for(intj=1; j<=n; J + +) {Maps[i][j]=min (maps[i][k]+Maps[k][j], maps[i][j]); }}intMain () { while(SCANF ("%d", &n)! =EOF) {memset (maps,0,sizeof(maps)); for(intI=2; i<=n; i++) { for(intj=1; j<i; J + +) { Chars[Ten]; scanf ("%s", s); if(s[0]=='x') Maps[i][j]= Maps[j][i] =INF; Else { intnum =0; for(intk=0; S[K]; k++) Num= num*Ten+ s[k]-'0'; MAPS[I][J]= Maps[j][i] =num; }}} Floyd (); intmax=0; for(intI=1; i<=n; i++) Max= Max (max, maps[1][i]); printf ("%d\n", Max); } return 0;}View Code
MPI Maelstrom---poj1502 (shortest path template)