Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
TT#include<cstdio> #include<iostream> #include<algorithm> #include<cstring> using namespace std; int f[101][101]={0}; int n,m; int p=0; int resmm[101]; int restt[101]; int main(){ int i,j,k,q; int x,y,z; while(cin>>n){ m=0; memset(f,0x3f,sizeof(f)); if(n==0) break; for(i=1;i<=n;i++){ cin>>k; f[i][i]=0; for(j=1;j<=k;j++){ cin>>x>>y; f[i][x]=y; m=max(m,x); } } for(k=1;k<=m;k++) for(i=1;i<=m;i++) for(j=1;j<=m;j++){ f[i][j]=min(f[i][j],f[i][k]+f[k][j]); } int resm=1,rest=9999; int minn=999999,maxx=0; for(i=1;i<=m;i++){ int tempm,tempt=0; for(j=1;j<=m;j++){ if(i!=j&&tempt<f[i][j]){ tempt=f[i][j]; } } if(tempt<rest){ rest=tempt; resm=i; } } resmm[p]=resm; restt[p]=rest; p++; } for(i=0;i<p;i++) cout<<resmm[i]<<" "<<restt[i]<<endl; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator