M - The Suspects

二次开发vba_CATIA VBA(VBS)二次开发:使用Search批量选择元素 在CATIA二次开发中很多在程序中进行自动交互的方法或函数都需要使用选择集作为参数,将几何元素按照要求批量添加到选择集中也是实现程序自动运行的有效方法。在前面的文章《CATIA使用VBA(VBS)二次开发时用户的交互选择》和《CATIA使用VBA(VBS)二次开发时工程图和草图位置的交互选择函数Indicate2D》中介绍了在CATIA VBA(VBS)二次开发中用户和选择集之间的交互操... 阅读详情

Time Limit: 1000MS Memory Limit: 20000KB 64bit IO Format: %I64d & %I64u

[Submit]   [Go Back]   [Status]

Description

Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. To minimize transmission to others, the best strategy is to separate the suspects from others. 
In the Not-Spreading-Your-Sickness University (NSYSU), there are many student groups. Students in the same group intercommunicate with each other frequently, and a student may join several groups. To prevent the possible transmissions of SARS, the NSYSU collects the member lists of all student groups, and makes the following rule in their standard operation procedure (SOP). 
Once a member in a group is a suspect, all members in the group are suspects. 
However, they find that it is not easy to identify all the suspects when a student is recognized as a suspect. Your job is to write a program which finds all the suspects.

Input

The input file contains several cases. Each test case begins with two integers n and m in a line, where n is the number of students, and m is the number of groups. You may assume that 0 < n <= 30000 and 0 <= m<= 500. Every student is numbered by a unique integer between 0 and n−1, and initially student 0 is recognized as a suspect in all the cases. This line is followed by m member lists of the groups, one line per group. Each line begins with an integer k by itself representing the number of members in the group. Following the number of members, there are k integers representing the students in this group. All the integers in a line are separated by at least one space. 
A case with n = 0 and m = 0 indicates the end of the input, and need not be processed.

Output

For each case, output the number of suspects in one line.

Sample Input

100 4
2 1 2
5 10 13 11 12 14
2 0 1
2 99 2
200 2
1 5
5 1 2 3 4 5
1 0
0 0

Sample Output

4
1
1


#include<stdio.h>
#define MAXN 35000
int father[MAXN];
int num[MAXN];
void make (int n)
{
	int e;
	for(e=0;e<n;e++)
	{
		father[e]=e;
		num[e]=1;
	}
}
int  find(int x)
{
	if(father[x]!=x)
	{
		father[x]=find(father[x]);
	}
	return father[x];
}
void union_set(int x,int y)
{
	int a,b;
	a=find(x);
	b=find(y);
	if(a==b)return ;
	if(num[a]>num[b])
		{
			father[b]=a;
			num[a]+=num[b];
		}
	else 
	{
		father[a]=b;
		num[b]+=num[a];
	}
}
int main()
{
	int x,y;
	int member,first,i;
	while(scanf("%d%d",&x,&y)!=EOF)
	{
		if(x==0&&y==0)break;
		int m;
		make(x);

		for(i=1;i<=y;i++)
		{
			scanf("%d%d",&m,&first);
			m--;
			while(m--)
			{
				scanf("%d",&member);
				union_set(first,member);
			}		
		}
		printf("%d\n",num[find(0)]);
	}
}


STM32 BLDC无刷电机霍尔信号捕获与换相控制实战解析 本文深入解析了STM32如何实现BLDC无刷电机的霍尔信号捕获与换相控制。详细阐述了硬件接口配置、定时器霍尔传感器模式的使用、抗干扰的滤波器与软件容错设计,以及中断服务与换相逻辑的实战代码。重点解决了信号抖动、换相不准等常见问题,旨在帮助开发者构建稳定可靠的电机驱动基础。 阅读详情

相关推荐

【工具使用】Keil常用的调试操作整理介绍

2、当选择了非0级优化时,调试可能会变得困难,具体表现在断点调试。该按钮是在进入了函数单步调试的时候,有时候你可能不必再执行该函数的剩余部分了,通过该按钮就直接一步执行完函数余下的部分,并跳出函数,回到函数被调用的置。:如果是在C语言窗口中,则是按单条语句执行,与单步调试不同的是,遇到函数不会进入函数内部,而是直接全速运行函数,并跳到下一条语句。但我的Keil软件中无法显示这个视图,并且通过修改系统试图,调试时,点击打开系统视图发生了闪退的现象,目前能想到的原因是:重新安装Keil,安装最新版本。

MEYOU_Cc 不吃香菜! 1万+

poj1611 The Suspects

poj1611 The Suspects 时空限制    1000ms/128MB Description Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. To m...

H优快云 312

KUKA-外部自动运行模板程序——个人设计模式&思路

用于说明KUKA与西门子PLC外部自动交互模板的设计思路与使用流程

qq_39024187的博客 5616

A - The Suspects

Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. To minimize transmission to others, the best strategy is to s...

三日小先森的博客 649

GX WORKS2通过交换机连接PLC的方法

三菱PLC连接方法的分享

weixin_64927621的博客 3620

【Python学习日记:PySide6】【持续更新】

说明:PySide6 是 Qt for Python 的一部分,是一个 Python 绑定库,可以用来创建跨平台的 GUI 应用程序。它将 Qt 框架的丰富功能带到了 Python 环境中,允许开发者使用 Python 编写 GUI 应用程序。

XLQ的博客 8045

POJ 1611 The Suspects

/*********************************** Problem: POJ 1611 The Suspects Time: 16MS Memory: 276K Accepted Time: 2009-08-19 20:26:36 Tip: 并查集 http://hi.baidu.com/fandywang_jlu/blog/item/b49e40893ddbb0b00f...

万猫学社 1万+

RK806S PMIC电源管理芯片调试

当点按PWRON按键时,rk806上电开始启动bootloader和uboot,在执行到此处时检测到是由于按键启动的,所以0x5d的值是0x80,0x74的值是0x80,在一般情况下,mode都默认是none的,所以mode值为11,因此就进入了我们的if判断,若是由于按键启动的,则直接调用rk8xx_shutdown函数关掉,进入这个函数会看到实际是通过i2c给0x72寄存器的BIT(0)写1,使其关机。当SoC在12V电源已经接入,且处于关机状态时,使用PWRON按键开机,0x74的值则为0x80。

Y1anoohh的博客 2545

The Suspects (求某一集合的个数)

Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. To minimize transmission to others, the best strategy is to s...

点点滴滴 290

LSTM 深度解析从原理推演到现代序列建模的演进

LSTM(Long Short-Term Memory,长短期记忆网络)是一种特殊的递归神经网络(RNN),它通过引入记忆单元(Cell State)来解决普通RNN在长序列数据处理中的梯度消失问题。LSTM可以在长时间的序列中捕捉依赖关系,是一种非常适合处理时间序列、自然语言处理、语音识别等任务的深度学习模型。在LSTM中,记忆单元(Cell State)是一个贯穿整个序列的数据通道,用于存储和传递关键信息。记忆单元在LSTM的时间步之间保持信息的持久性,可以看作是一个长期记忆的“容器”。

hello.reader 3万+

EtherCAT主站SOEM -- 19 --Qt-Soem通过CSP模式(周期同步位置模式)控制一个电机转圈圈

以上就是EtherCAT主站SOEM – 19 --Qt-Soem通过CSP模式(周期同步位置模式)控制一个电机转圈圈的内容。有不明白的地方欢迎留言;有建议欢迎留言,我后面编写文档好改进。创作不容,如果文档对您有帮助,记得给个赞。

常驻客栈的博客--嵌入式EtherCAT 1998

POJ1611The Suspects(并查集)

Description 严重急性呼吸系统综合症( SARS), 一种原因不明的非典型性肺炎,从2003年3月中旬开始被认为是全球威胁。为了减少传播给别人的机会, 最好的策略是隔离可能的患者。 在Not-Spreading-Your-Sickness大学( NSYSU), 有许多学生团体。同一组的学生经常彼此相通,一个学生可以同时加入几个小组。为了防止非典的传播,NSYSU收集了所有学生团体

菜鸟的自我修养 333

28-Halcon-- union_object_model_3d函数功能(用于3D模型融合)

Halcon算子union_object_model_3d是专业的3D模型融合工具,主要用于多视图拼接、部件组装和多源数据融合。该算子支持点云、网格和参数化模型输入,提供多种融合算法选择,包括基础点云拼接('points_cloud')、网格融合('mesh')和精确CAD布尔运算('cad')。工业应用涵盖逆向工程扫描拼接、汽车部件虚拟装配等场景,支持性能优化如空间分区和流式处理。算子还解决颜色属性融合、法向量保留等特殊需求,并提供拼接误差分析、拓扑验证等质量评估手段。最佳实践包含动态场景重建工作流和CA

weixin_45590420的博客 1055

The Suspects

Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. To minimize transmission to others, the best strategy is to se

海绵的博客 251

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

POJ - 1611The Suspects-并查集

POJ - 1611 The Suspects Time Limit: 1000MS   Memory Limit: 20000KB   64bit IO Format: %I64d & %I64u Submit Status Description 严重急性呼吸系统综合症( SARS), 一种原因不明的非典型性肺炎,从2003年3

qq_18661257的专栏 1014

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

poj 1611 The Suspects

http://poj.org/problem?id=1611 The Suspects Time Limit:1000MS     Memory Limit:20000KB     64bit IO Format:%I64d & %I64u Submit Status Description Severe acute respiratory s

大太阳 475

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

ZOJ 1789 The Suspects

ZOJ 1789 The Suspects(并查集) 题目链接:https://zoj.pintia.cn/problem-sets/91827364500/problems/91827365288 The Suspects Time Limit: 2000 msMemory Limit: 65536 KB Severe acute respiratory syndrome (SARS), an ...

weixin_43823753的博客 132

poj 1611 The Suspects(并查集)

题目链接:poj 1611 The Suspects 题目大意:学校有若干个社团,给出每个社团的成员,现在0号同学得了流感,问说至少应该隔离哪些人。 解题思路:并查集,开一个数组用于记录当前集合的人数,在合并两个集合的同时将人数相加,作为新集合的人数。 #include #include const int N = 30005; int n, m, f[N

不慌不忙、不急不躁 1057

The Suspects POJ - 1611 并查集

The Suspects POJ - 1611 知识点:并查集 我这里把查询和合并进行了优化,喜欢的话可以拿来当模板 在这里插入代码片#include<iostream> #include<algorithm> #define fori for(i=0;i<n;i++) #define fori1 for(i=1;i<=n;i++) #define ll lon...

ch_huibw的博客 145

POJ1611 The Suspects (并查集)

POJ 1611 第一道并查集方面的题目。 题意分析: 对于每组测试数据: 这个学校有n个人,m小组,依次给出m个小组的信息,每行一个小组。 每个小组的信息包括,k,表示有k个人,k个数字,分别是这k个人的ID。 现在ID为0的人感染了病毒,他及他的小组成员全部会感染病毒,每个小组成员都会感染自己所在小组的成员(每个成员可以加入多个小组)。问现在总共有多少个人感染了病

xx_ii 685

【并查集-size[ ]】POJ 1611 The Suspects

POJ 1611 The Suspects #include <iostream> #include <cstdio> #include <algorithm> #include <queue> #include <cmath> #include <cstring> #include <string> #inclu...

L_X_ 145

The Suspects POJ1611

The Suspects Time Limit: 1000MS   Memory Limit: 20000K Total Submissions: 13311   Accepted: 6297 Description Severe acute respiratory syndrome (SARS), an atypical pne

天堂人间 4670

poj union_find相关之1611 The Suspects

poj union-find 1611 The Suspects

ziqi9216的博客 295

POJ.1611 The Suspects (并查集)

POJ.1611 The Suspects (并查集)题意分析对于每组测试数据: 这个学校有n个人,m小组,依次给出m个小组的信息,每行一个小组。 每个小组的信息包括,k,表示有k个人,k个数字,分别是这k个人的ID。 现在ID为0的人感染了病毒,他及他的小组成员全部会感染病毒,每个小组成员都会感染自己所在小组的成员(每个成员可以加入多个小组)。问现在总共有多少个人感染了病毒? 比较裸的并查

Pengwill's Blog 300
上一篇: L - Play on Words
下一篇: N - 食物链
翔蝈蝈
博客等级 码龄16年 25粉丝 69原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值