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 |
给的数据过了,但是还是wa,求高人修改#include<iostream> using namespace std; int main(void) { int arr[201][201]; int n,m,i,j,k,min,mini; int judge[101]; while(cin>>n&&n) { //memset(arr,1,sizeof(arr)); for(i=1;i<=n;i++) for(j=1;j<=n;j++) arr[i][j]=20; memset(judge,0,sizeof(judge)); for(i=1;i<=n;i++) { cin>>m; arr[i][i]=0; for(j=0;j<m;j++) { cin>>k; cin>>arr[i][k]; } } for(k=1;k<=n;k++) for(i=1;i<=n;i++) for(j=1;j<=n;j++) if(arr[i][j]>arr[i][k]+arr[k][j]) { arr[i][j]=arr[i][k]+arr[k][j]; } for(i=1;i<=n;i++) for(j=1;j<=n;j++) if(judge[i]<arr[i][j]) judge[i]=arr[i][j]; min=20; for(i=1;i<=n;i++) if(judge[i]<min) { min=judge[i]; mini=i; } if(min>10) cout<<"disjoint"<<endl; else cout<<mini<<' '<<min<<endl; cout<<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