标签:style blog color io os for sp div log
#include <stdio.h> #include <iostream> #include <memory.h> using namespace std; int stb[102][102]; //int min(int x,int y) //{ // return x<y?x:y; //} void Floyd(int n) { int i,j,k; for(k=1;k<=n;k++) for(i=1;i<=n;i++) for(j=1;j<=n;j++) stb[i][j]=min(stb[i][j],stb[i][k]+stb[k][j]); } int main() { // freopen("in.txt","r",stdin); int i,j; int num,num1,n,dis; int line,ansmix,linemax; while(1) { scanf("%d",&num); if(num==0) break; for(i=1;i<=num;i++) for(j=1;j<=num;j++) stb[i][j]=1000010; for(i=1;i<=num;i++) { scanf("%d",&num1); stb[i][i]=0; for(j=0;j<num1;j++) { scanf("%d %d",&n,&dis); stb[i][n]=dis; } } Floyd(num); ansmix=1000010; for(i=1;i<=num;i++) { linemax=0; for(j=1;j<=num;j++) { if(stb[i][j]>linemax) { linemax=stb[i][j]; } } if(linemax<ansmix) { ansmix=linemax; line=i; } } if(ansmix==1000010) printf("disjoint\n"); else printf("%d %d\n",line,ansmix); } return 0; }
标签:style blog color io os for sp div log
原文地址:http://www.cnblogs.com/balfish/p/4015193.html