摘要: http://poj.org/problem?id=3630View Code 1 #include<stdio.h> 2 #include<string.h> 3 struct node 4 { 5 int count ; 6 int next[11] ; 7 }tr[100010] ; 8 int flag, num ; 9 void node()10 {11 tr[num].count = 0 ;12 memset(tr[num].next,0,sizeof(tr[num].next)) ;13 }14 void creat(char *s)15 {16... 阅读全文
posted @ 2013-02-21 20:18 yelan@yelan 阅读(179) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=1611View Code 1 #include<stdio.h> 2 int father[30001], num[30001] ; 3 int i ; 4 void Init(int n) 5 { 6 for(i=0; i<n; i++) 7 { 8 father[i] = i ; 9 num[i] = 1 ;10 }11 }12 int find(int x)13 {14 if(father[x]!=x)15 father[x] = find(father[x])... 阅读全文
posted @ 2013-02-21 18:57 yelan@yelan 阅读(171) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=2524View Code 1 #include <stdio.h> 2 int father[50001] ; 3 int find(int x) 4 { 5 while(x!=father[x]) 6 x = father[x] ; 7 return x ; 8 } 9 void merge(int x,int y)10 {11 int fx , fy ;12 fx = find(x) ;13 fy = find(y) ;14 if(fx!=fy)15 father[fx]... 阅读全文
posted @ 2013-02-21 14:49 yelan@yelan 阅读(162) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1272View Code 1 #include <stdio.h> 2 int father[100001],k[100001]; 3 int flag ; 4 int find(int x) 5 { 6 while(x!=father[x]) 7 x = father[x] ; 8 return x ; 9 }10 void merge(int x,int y)11 {12 int fx , fy ;13 fx = find(x) ;14 fy = find... 阅读全文
posted @ 2013-02-21 13:55 yelan@yelan 阅读(349) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1232View Code 1 #include <stdio.h> 2 #include<string.h> 3 int father[1001]; 4 int find(int x) 5 { 6 if(x!=father[x]) 7 father[x] = find(father[x]); 8 return father[x]; 9 }10 void merge(int x,int y)11 {12 int fx, fy ;13 fx = find(x) ;14 ... 阅读全文
posted @ 2013-02-21 10:02 yelan@yelan 阅读(126) 评论(0) 推荐(0) 编辑