Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

哈哈,我忘了写disjoint竟然过了。。。rp太好了。。。。

Posted by hanjialong at 2007-10-20 21:46:16 on Problem 1125
注意:没有处理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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator