Qiuqiqiu  
不管道路多么崎岖坎坷,我永远不停下追逐梦想的脚步!

2011年12月1日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1233赤裸裸的最小生成树Kruskal我的代码 1 #include <stdio.h> 2 #include <stdlib.h> 3 const int M=10000,N=100; 4 struct edge 5 { 6 int u,v,w; 7 }e[M]; 8 int set[N],n,m; 9 int cmp(const void *a,const void *b)10 {11 return ((edge*)a)->w - ((edge*)b)->w;12 }1 阅读全文
posted @ 2011-12-01 21:51 Qiuqiqiu 阅读(120) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1232赤裸裸的并查集我的代码 1 #include <stdio.h> 2 const int N=1000; 3 int set[N]; 4 int find(int x) 5 { 6 return set[x]==x ? x : set[x]=find(set[x]); 7 } 8 void merge(int x,int y) 9 {10 set[find(x)]=find(y);11 }12 int main()13 {14 int n,m;15 while (scan... 阅读全文
posted @ 2011-12-01 21:48 Qiuqiqiu 阅读(117) 评论(0) 推荐(0) 编辑