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

我的路径压缩函数

Posted by kuailezhish at 2012-02-20 18:43:36 on Problem 1182
int father[maxn],r[maxn];		//r数组记录当前节点和其父亲的关系

int findfather(int x,int &sum){
	if (father[x]!=x){
		father[x]=findfather(father[x],sum);
		sum=(sum+r[x])%3;		
	}
	r[x]=sum;
	return father[x];
}

r初始化皆为0;
传参:fx=findfather(x,tem=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