![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
并查集
pbj1203
这个作者很懒,什么都没留下…
展开
-
poj 2524 Ubiquitous Religions
经典并查集 #include using namespace std; int m,n,case_t,parent[50050]; int num[50050]; void makeset() { int x; for(x=1;x<=n;x++) { parent[x]=x; num[x]=0; } } int findset(int x) { if(parent[x]!=原创 2011-02-15 23:34:00 · 381 阅读 · 0 评论 -
poj 1308 Is It A Tree?
#include using namespace std; struct node { int x,y; }t; int tt,case_t; int parent[105]; bool flag[105]; void makeset() { int xx; for(xx=1;xx<100;xx++) { parent[xx]=xx; flag[xx]=0; } } int原创 2011-02-15 23:32:00 · 330 阅读 · 0 评论 -
poj 2492 A Bug's Life
#include using namespace std; int m,n,case_t,t,parent[5005]; int num[5005],opp[5005]; bool flag; void makeset() { int x; for(x=1;x<=n;x++) { parent[x]=x; num[x]=0; opp[x]=-1; } } int finds原创 2011-02-15 23:29:00 · 407 阅读 · 0 评论 -
poj 1611 The Suspects
#include using namespace std; int n,m,k,pre[30010],ran[30010]; void ini(int x) { pre[x]=x; ran[x]=0; } int findx(int x) { if(pre[x]==x) return x; pre[x]=findx(pre[x]); return pre[x]; } void u原创 2011-02-15 23:26:00 · 362 阅读 · 0 评论