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 |
哈哈,我忘了写disjoint竟然过了。。。rp太好了。。。。注意:没有处理disjoint!!!!!!!!!! Source Code Problem: 1125 User: hanjialong Memory: 184K Time: 15MS Language: C++ Result: Accepted Source Code #include<iostream> using namespace std; int distant[101][101]; int t[101]; const int maxint=999999999; main() { int n; int m; int i,j,k; int people,time; int max,min,mini; cin>>n; while(n) { for(i=1;i<=n;i++) for(j=1;j<=n;j++) distant[i][j]=maxint; for(i=1;i<=n;i++) distant[i][i]=0; for(i=1;i<=n;i++) { cin>>m; for(j=1;j<=m;j++) { cin>>people>>time; distant[i][people]=time; } } for(k=1;k<=n;k++) for(i=1;i<=n;i++) for(j=1;j<=n;j++) if(distant[i][k]+distant[k][j]<distant[i][j]) distant[i][j]=distant[i][k]+distant[k][j]; for(i=1;i<=n;i++) { max=0; for(j=1;j<=n;j++) if(distant[i][j]>max) max=distant[i][j]; t[i]=max; } min=maxint; for(i=1;i<=n;i++) if(t[i]<min) { min=t[i]; mini=i; } cout<<mini<<" "<<min<<endl; cin>>n; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator