Hdu1213 - How Many Tables - 并查集
来源:互联网 发布:古力娜扎长相知乎 编辑:程序博客网 时间:2024/06/09 18:02
#include<stdio.h>#include<string.h>int p[10000],a,ap[10000],b,bp[10000],m,c,n;int find(int n){if(p[n]!=n){p[n]=find(p[n]);}return p[n];}int main(){int i,k,t;scanf("%d",&t);for(k=0;k<t;k++){scanf("%d%d",&n,&m);for(int i=1;i<=n;i++) p[i]=i;for(int i=1;i<=m;i++){scanf("%d%d",&a,&b);ap[i]=find(a);bp[i]=find(b);p[ap[i]]=bp[i];}for(c=0,i=1;i<=n;i++){if(p[i]==i){c++;}}printf("%d\n",c);}return 0;}
0 0
- 【hdu1213】How Many Tables【并查集】
- How Many Tables hdu1213 并查集
- hdu1213(How Many Tables 并查集)
- Hdu1213 - How Many Tables - 并查集
- HDU1213 How Many Tables 【并查集】
- HDU1213 How Many Tables【并查集】
- HDU1213 How Many Tables 【并查集】
- hdu1213 How Many Tables(并查集)
- How Many Tables--hdu1213(并查集)
- HDU1213-How Many Tables 并查集
- HDU1213 How Many Tables - 并查集
- hdu1213 How Many Tables 并查集
- HDU1213 How Many Tables(并查集)
- HDU1213 How Many Tables 并查集
- hdu1213 How Many Tables 并查集
- HDU1213 How Many Tables(并查集)
- hdu1213 How many tables 并查集
- HDU1213 How Many Tables 并查集
- 奇偶调序问题
- 侧边抽屉式导航可能会降低你产品一半的用户参与度
- HDU 4539 状压DP
- tomcat 服务器拒绝了链接
- java 图像灰度直方图
- Hdu1213 - How Many Tables - 并查集
- 探秘抽屉导航的前生今世
- C++ 中的内存问题
- 投资
- 代理模式
- POJ3384-Feng Shui
- 交互设计的职能——交互设计师具体做哪些内容?
- 费用流模板
- 移动应用侧边栏交互的利与弊个与解决方法