1、题目链接地址

  http://poj.org/problem?id=1161

2、源代码

#include <iostream>
using namespace std;
int parent[];
int suspect[]; int find(int x)
{
if(parent[x] == x)
{
return x;
}
else
{
return parent[x] = find(parent[x]);
}
} void Union(int a, int b)
{
int x = find(a);
int y = find(b);
if(x == y)
{
return;
}
parent[y] = x;
suspect[x] = suspect[x] + suspect[y];
} int main()
{
int m, n;
int a, b, c;
int x;
int i;
while(cin >> m >> n)
{
if(m == && n == )
{
break;
} for(i = ; i <= m; i++)
{
parent[i] = i;
suspect[i] = ;
} while(n--)
{
cin >> a >> b;
a--;
while(a--)
{
cin >> c ;
if(find(c) != find(b))
{
Union(c, b);
}
}
} cout << suspect[find()] << endl;
}
return ;
}

最新文章

  1. SQL Server的镜像是基于物理块变化的复制 镜像Failover之后数据的预热问题
  2. [译] 理解PHP内部函数的定义(给PHP开发者的PHP源码-第二部分)
  3. css基础知识
  4. Android (二维码)关于java.lang.UnsatisfiedLinkError的小案例
  5. BC#32 1002 hash
  6. tagName和nodeName的区别
  7. C\C++拾遗------C#程序员重温C\C++之要点
  8. Windows安全模式的妙用
  9. idhttp.post方式 调用datasnap rest 远程方法
  10. mvc3.0中[ValidateInput(false)]失效的问题
  11. (转载)Convolutional Neural Networks卷积神经网络
  12. sql2005如何附加数据库
  13. 上传jar包到Apache Archiva本地仓库
  14. css(二)
  15. Linux企业级项目实践之网络爬虫(1)——项目概述及准备工作
  16. javaScript 工作必知(二) null 和undefined
  17. pwnable.kr brainfuck之write up
  18. 我自己总结的C#开发命名规范整理了一份
  19. (五十六)iOS多线程之NSOperation
  20. Java面试题中常考的容易混淆的知识点区别

热门文章

  1. 【tensorflow:Google】三、tensorflow入门
  2. Failed to export application
  3. [置顶] Xposed也要热更新
  4. Python标准库之time和datetime
  5. tab显示不同数据
  6. vi下的查找替换命令
  7. c#模拟键盘输入
  8. django中的@login_required
  9. Android 比对APK的签名信息
  10. 错过的sql语句