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

Re:是不是没有disjoint?

Posted by frkstyc at 2005-04-09 09:52:30 on Problem 1125
In Reply To:是不是没有disjoint? Posted by:TN at 2005-04-09 09:47:46
无语了……找不到一个能去所有点的点就disjoint
void solve(void)
{
	int i, j, k, m;
	if(N == 1)
	{
		puts("1 0");
		return;
	}
	for(i = 0; i < N; i++)
	{
		for(j = 0; j < N; j++)
		{
			if(j != i)
			{
				for(k = 0; k < N; k++)
				{
					if(k != i && k != j)
					{
						int temp = dist[i][k] + dist[k][j];
						if(dist[i][k] > 0 && dist[k][j] > 0 && (dist[i][j] < 0 || dist[i][j] > temp))
						{
							dist[i][j] = temp;
						}
					}
				}
			}
		}
	}
	for(i = 0; i < N; i++)
	{
		for(j = 0; j < N; j++)
		{
			if(i != j && dist[i][j] < 0)
			{
				break;
			}
		}
		if(j < N)//这个点不能所有点都去
		{
			continue;
		}
		for(j = 0; j < N; j++)
		{
			if(j != i && dist[i][j] > dist[i][i])
			{
				dist[i][i] = dist[i][j];//dist[i][i]记最小值
			}
		}
	}
	k = -1;
	m = 0x7FFFFFFF;
	for(i = 0; i < N; i++)
	{
		if(dist[i][i] > 0 && dist[i][i] < m)
		{
			k = i;
			m = dist[i][i];
		}
	}
	if(k >= 0)
	{
		printf("%d %d\n", k + 1, m);
	}
	else
	{
		puts("disjoint");
	}
}

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