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::)我这么做对么?貌似思路应该没错,可是wa..

Posted by 1050310209 at 2007-02-24 19:12:28 on Problem 1797
In Reply To::)谢谢. Posted by:MIBG at 2006-03-18 23:02:00
int Dijstra(int a, int b)
{
	int i, j, mini, h, w;
	int d[1001];
	for(i = 0; i <= n; i++)
	{
		d[i] = 0;
		flag[i] = 0;
	}
	d[a] = maxnum;
	for(i = 0; i < n; i++)
	{
		mini = -1;
		for(j = 1; j <= n; j++)
		{
			if(flag[j] == 0 && d[j] > 0)
			{
				mini = d[j];
				h = j;
				break;
			}
		}
		if(mini == -1)break;
		else flag[h] = 1;
		for(j = 1; j <= n; j++)
		{
			if(flag[j] == 0 && matrix[h][j] != maxnum)
			{
				w = d[h] < matrix[h][j] ? d[h] : matrix[h][j];
				d[j] = d[j] > w ? d[j] : w;
			}
		}
	}
	return d[b];
}

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