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:做过的人帮忙找原因,代码很容易看懂!!!

Posted by sunmoonstar at 2008-08-04 18:10:59 on Problem 2513
In Reply To:做过的人帮忙找原因,代码很容易看懂!!! Posted by:caizhicong0503 at 2008-08-04 17:47:32
void Union(int x,int y)
{
	int rootx = find(x);
	int rooty = find(y);
	if(rootx == rooty) return ;
	if(rank[x]>rank[y]) Father[y] = x;
	else {
		Father[x] = y;
		if(rank[x] == rank[y]) rank[x]++;
	}
}

->
void Union(int x,int y)
{
	int rootx = find(x);
	int rooty = find(y);
	if(rootx == rooty) return ;
	Father[Father[x]] = Father[y];
}

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