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 |
贴码#include<iostream> #include<string.h> #include<algorithm> using namespace std; const int maxn=100,maxm=1000000; int A[maxn][maxn]; int main() { int n,m,a,b; while (cin>>n && n) { for (int i=0;i<n;i++) for (int j=0;j<0;j++) A[i][j]=maxm; for (int i=0;i<n;i++) { scanf("%d",&m); for (int j=0;j<m;j++) { scanf("%d%d",&a,&b); A[i][a-1]=b; } } for (int k=0;k<n;k++) for (int i=0;i<n;i++) for (int j=0;j<n;j++) if (i!=j) A[i][j]=min(A[i][j],A[i][k]+A[k][j]); int k,ans=maxm; for (int i=0;i<n;i++) { int max=0; for (int j=0;j<n;j++) if (i!=j && A[i][j]>max) max=A[i][j]; if (max<ans) { ans=max; k=i; } } cout<<k+1<<" "<<ans<<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