摘要: #include"stdio.h"int n,m,fa[1005];int find(int w){ int temp=w;//并查集的路径压缩 while(temp!=fa[temp]) temp=fa[temp]; fa[w]=temp; return temp;}int cal(){ int i,sum=0,a,b,x,y; for(i=0;i<=n;i++) fa[i]=i; for(i=0;i<m;i++) { scanf("%d%d",&x,&y); a=find(x); ... 阅读全文
posted @ 2012-09-12 21:42 朝圣の路 阅读(197) 评论(0) 推荐(0) 编辑