| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
我的路径压缩函数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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator