摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=3635并查集改变一个点的值,同时要改变他儿子的值,用并查集实现View Code 1 #include <cstdio> 2 #include <cstring> 3 using namespace std; 4 5 const int N=10010; 6 int set[N],cnt[N],sum[N]; 7 int find(int x) 8 { 9 if(x==set[x]) return x;10 int t=find(set[x]);11 cnt[x]+=cnt[set..
阅读全文
posted @ 2012-04-27 15:24
Qiuqiqiu
阅读(151)
推荐(0)
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=3047并查集 记录各点到根的距离View Code 1 #include <cstdio> 2 #include <cstring> 3 using namespace std; 4 5 const int N=50010,md=300; 6 int set[N],sum[N]; 7 int find(int x) 8 { 9 if(set[x]==x) return x;10 int t=find(set[x]);11 sum[x]+=sum[set[x]];12 ret...
阅读全文
posted @ 2012-04-27 14:22
Qiuqiqiu
阅读(188)
推荐(0)