摘要: http://poj.org/problem?id=1182 重点依旧是用rank记录相对于根节点的关系,并及时跟新rank的值。code:#include<cstdio>usingnamespacestd;intf[50001];intr[50001];//与根节点的关系intfind_Set(intx){inttemp;if(x==f[x])returnx;temp=f[x];f[x]=find_Set(temp);r[x]=(r[temp]+r[x])%3;/*r[x]是相对于x原根节点temp的关系值,现在相对根节点已不是temp故更新r[x]值时要加上temp相对于其根节 阅读全文
posted @ 2012-02-01 00:30 追逐. 阅读(230) 评论(0) 推荐(0) 编辑