biying

导航

2013年4月18日 #

hdu1232简单并差集(2)

摘要: View Code 1 #include<stdio.h> 2 int father[1005]; 3 int findset(int x) 4 { 5 return x==father[x]?x:(father[x]=findset(father[x])); 6 } 7 int main() 8 { 9 int n,m,i,a,b,x,y,k;10 while(scanf("%d %d",&n,&m)&&n)11 {12 13 for(i=1;i<=n;i++)14 {15 father[i]=i;16... 阅读全文

posted @ 2013-04-18 21:27 biying 阅读(136) 评论(0) 推荐(0)

hdu1213简单并差集

摘要: 第一次做并差集,算是留个纪念吧~~View Code 1 #include <cstdio> 2 #include <cstring> 3 #include <iostream> 4 #include <algorithm> 5 using namespace std; 6 const int MAXN = 1010; 7 int M, N; 8 int parent[MAXN]; 9 10 int myfind(int i) {11 int r = i;12 while (parent[r] != r) {13 r = parent[r];14 阅读全文

posted @ 2013-04-18 21:02 biying 阅读(147) 评论(0) 推荐(0)