E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
Suspects
POJ1611 The
Suspects
(并查集)
本文出自:http://blog.csdn.net/svitter题意:0号学生染病,有n个学生,m个小组。和0号学生同组的学生染病,病可以传染。 输入格式:n,m 数量 学生编号1,2,3,4 //m个分组题解:最为典型的并查集。 解法一:求出所有的集
svtter
·
2014-10-17 23:00
算法
并查集
POJ1611 The
Suspects
(并查集)
本文出自:http://blog.csdn.net/svitter题意:0号学生染病,有n个学生,m个小组。和0号学生同组的学生染病,病可以传染。 输入格式:n,m 数量 学生编号1,2,3,4 //m个分组题解:最为典型的并查集。 解法一:求出所有的集
svtter
·
2014-10-17 23:00
算法
并查集
uva1076 - Password
Suspects
AC自动机+状态压缩DP
YouarethecomputerwhizforthesecretorganizationknownastheSneakyUndergroundSmugPerpetratorsofEvilCrimesandThefts.ThetargetforSUSPECT'slatestevilcrimeistheirgreatestfoe,theIndescribablyCleverPolicemen'sCl
corncsd
·
2014-09-12 20:00
uva 1076 - Password
Suspects
(AC自动机+记忆化搜索)
题目链接:uva1076-PasswordSuspects题目大意:有一个长度为n的密码,存在m个子串,问说有多少种字符串满足,如果满足个数不大于42,按照字典序输出。解题思路:根据子串构建AC自动机,然后记忆化搜索,dp[i][u][s]表示第i个字符,在u节点,匹配s个子串。#include #include #include #include #include #include #inclu
u011328934
·
2014-09-05 22:00
POJ1611——The
Suspects
DescriptionSevereacuterespiratorysyndrome(SARS),anatypicalpneumoniaofunknownaetiology,wasrecognizedasaglobalthreatinmid-March2003.Tominimizetransmissiontoothers,thebeststrategyistoseparatethesuspectsf
Guard_Mine
·
2014-09-05 13:00
并查集
UVA 1076 - Password
Suspects
(AC自动机+DP)
UVA1076-PasswordSuspects题目链接题意:一个密码,给定m个已知子串,求这个密码最多有几种表示方式,如果小于42种,就输出这些密码思路:先利用已有子串构造AC自动机,需要改造一下的地方是每个叶子结点为(1 #include #include #include #include #include usingnamespacestd; typedeflonglongll; con
u011217342
·
2014-08-22 16:00
POJ-1611- The
Suspects
大概的题意:现在编号为0的得了一种病,然后给出几组数据,每组代表这些人是有关系,如果其中一个人得病,那么其他人也将得病,问被0传染病的有多少。就是用并查集记录这些人的关系,在用另一个数组保存这类关系有多少人。#include constintmaxn=30000+10; intpa[maxn],pa1[maxn]; //pa1[]数组用于存储跟他有关系的人数。 intcha(intk)//基本的并
KJBU2
·
2014-08-12 09:00
POJ 1611 The
Suspects
The
Suspects
Time Limit: 1000MSMemory Limit: 20000KB64bit IO Format: %I64d & %I64u [Submit] 
·
2014-08-11 14:00
poj
POJ1611_The
Suspects
TheSuspectsTimeLimit:1000MS MemoryLimit:20000KTotalSubmissions:22366 Accepted:10875DescriptionSevereacuterespiratorysyndrome(SARS),anatypicalpneumoniaofunknownaetiology,wasrecognizedasaglobalthreatinm
u011676797
·
2014-08-08 20:00
POJ 1611 The
Suspects
(并查集)
TheSuspectsTimeLimit: 1000MS MemoryLimit: 20000KTotalSubmissions: 22296 Accepted: 10842DescriptionSevereacuterespiratorysyndrome(SARS),anatypicalpneumoniaofunknownaetiology,wasrecognizedasaglobalthrea
u013263923
·
2014-08-05 21:00
POJ 1611 The
Suspects
TheSuspectsTimeLimit:1000MSMemoryLimit:20000KTotalSubmissions:22220Accepted:10808DescriptionSevereacuterespiratorysyndrome(SARS),anatypicalpneumoniaofunknownaetiology,wasrecognizedasaglobalthreatinmid
Tc_To_Top
·
2014-08-03 13:00
并查集
hduoj
The
Suspects
The SuspectsTime Limit: 1000MS Memory Limit: 20000KTotal Submissions: 22143 Accepted: 10762DescriptionSevere acute respiratory syn
zchlww
·
2014-07-31 11:00
namespace
合并
iostream
[ACM] POJ 1611 The
Suspects
(并查集,输出第i个人所在集合的总人数)
TheSuspectsTimeLimit: 1000MS MemoryLimit: 20000KTotalSubmissions: 21586 Accepted: 10456DescriptionSevereacuterespiratorysyndrome(SARS),anatypicalpneumoniaofunknownaetiology,wasrecognizedasaglobalthrea
sr19930829
·
2014-07-17 08:00
ACM
并查集
POJ 1611The
Suspects
(简单并查集)
题目地址:http://poj.org/problem?id=1611网络流先慢慢看着。。先开始并查集专题吧。。这题很简单,就是一道并查集模板题。不多说。。#include #include #include #include #include #include #include #include #include usingnamespacestd; intbin[40000],n; intfi
u013013910
·
2014-06-11 17:00
编程
算法
C语言
poj
poj 1611 The
Suspects
(并查集)
题目:poj1611TheSuspects(并查集)题目大意:现在0号同学染上了sars,这样和0号同学一组的同学就都是被怀疑的对象。问被怀疑的人数。解题思路:并查集,如果两个组有关连,例如有一个共同的人的话,那么前一组里有被怀疑者(感染者0号),后一组也有被怀疑者。这样把有关系的同学都关联起来,最后输出0这组的人数就可以了。代码:#include constintN=30005; intf[
u012997373
·
2014-04-22 23:00
POJ 1611 The
Suspects
题目链接:http://poj.org/problem?id=1611详细题解:裸的并查集 把每一个group排一个序,最小的为根,当然,如果其中的某个节点的根最小,那么这个这个节点的根就为这个group的根,这样就可以把所有与0有关系的节点归纳到一起啦啦啦……水吧0.0#include #include #include usingnamespacestd; #defineN31000 intF
fjy4328286
·
2014-04-15 18:00
zoj 1789 The
Suspects
好高兴,又AC一道,不过是很类似的两道。。还是好高兴呀思想跟2833是一样的,不过要重新设计输入和输出。老师上课又重新讲解了一下,因为嫌疑人已知是0,所以加入集中时应该默认让数值小的做树根,即最终让零做树根,这样子,只改了一点点,最后只要直接输出树根为零的树的大小就可以了。。。。。。。。。。。。。只是改良了一点点,但思想非常重要。。下面的程序仍然还是没有改的。。太懒了。。==// // //#i
chen_xinjia
·
2014-04-13 16:00
ZOJ
并查集
POJ 1611 The
Suspects
并查集
表示刚接触并查集做这道题对并查集有些感觉了,刚开始的时候想的一种方式有bug,最终调试了半个小时终于知道为什么错了T_T题目大意:对于n个学生编号为0至n-1,其中编号为0的学生感染了病毒,接下来给出m组人,每行开头表示该组有多少人,接下来是该组的组员编号,与0在同一组或有同组的人与0在一组的人视为感染,求感染的总人数。很明显的一个并查集问题,就是分组的问题,问0所在的集合的元素数量。大致思路:对
u013738743
·
2014-04-10 17:00
set
poj
并查集
the
disjoint
Suspects
1611
POJ 1611 The
Suspects
(并查集)
POJ1611TheSuspects(并查集)http://poj.org/problem?id=1611题意: 现在有n个学生(从0号到n-1号),其中0号学生是有可能非典的,只要和被怀疑有非典的学生在一个社团的学生都是有可能有非典的且需要被隔离,但是学校有很多社团,所以现在要你求一共有多少学生需要被隔离? 输入:多组实例.每个实例第一行n和m(0 #include #includ
u013480600
·
2014-03-11 11:00
ACM
POJ 1611 The
Suspects
(并查集)
链接:http://poj.org/problem?id=1611TheSuspectsTimeLimit: 1000MS MemoryLimit: 20000KTotalSubmissions: 20031 Accepted: 9730DescriptionSevereacuterespiratorysyndrome(SARS),anatypicalpneumoniaofunknownaetio
u012823258
·
2014-03-05 16:00
合并
POJ 1611 The
Suspects
这道题就是说0号童鞋是有患病嫌疑的,和0号童鞋一个组的也有患病嫌疑,和有患病嫌疑在一个组的同学也有患病嫌疑,问一共有几个孩子有患病嫌疑。首先,可以把一个组(更准确的说是被传染的)的同学放在一个集合里,然后记录下这个集合的人数,最后找到0童鞋所在的集合的人数。#include #include #definemax30005 usingnamespacestd; intrank[max];//秩
u011281853
·
2013-11-15 10:00
poj 1611 - The
Suspects
(并查集)
传说中的大水题,我却纠结了好久。原因是我的思路逻辑上有点有bug。思路:很明显的并查集题目,把每组的成员都放到一个集合里面,然而我为了保证符合条件的答案都在0这个集合中,所以我对每个分组都是合并到改组中编号最小的那个节点上了,恰恰是这个想法成了我代码的bug,出错的原因是每组的节点都合并到了最小的点上,但并不能保证合并后的那个集合的节点是编号最小的,因为这还牵扯到父节点的问题。例如某个分组中有10
shankeliupo
·
2013-10-20 11:00
POJ 1611 The
Suspects
简单的并查集的应用,统计和0联通的点的个数,约等于模板题。。。。。。手残没有判断两个点的根节点是否相等。。。。。贡献了五个WA......1#include 2#include 3#include 4 5usingnamespacestd; 6 7intstu[30010],num[30010]; 8 9intfind(intx) 10{ 11returnstu[x]==x?x
u012161037
·
2013-09-18 15:00
The
Suspects
(并查集)
The
Suspects
Time Limit: 1000MS Memory Limit: 20000K Total Submissions:
Simone_chou
·
2013-08-20 22:00
并查集
POJ 1611 The
Suspects
The
Suspects
Time Limit: 1000MS Memory Limit: 20000K Total Submissions: 
·
2013-08-14 17:00
poj
poj 1611 The
Suspects
/* TheSuspects TimeLimit:1000MSMemoryLimit:20000K TotalSubmissions:18514Accepted:8952 Description Severeacuterespiratorysyndrome(SARS),anatypicalpneumoniaofunknownaetiology,wasrecognizedasagl
locusxt
·
2013-07-24 18:00
poj
cpp
POJ 1611 The
Suspects
http://poj.org/problem?id=1611题目大意:有n个学生(标号为0 to n-1),m个学生社团,给出每个社团里所有学生的标号,并假设0号学生患有SARS(社团里只要用一个学生患病,则整个社团里的学生都会被隔离),问最后一共会有多少学生被隔离?这是一个最基础的并查集的应用,扫描每一个社团,只要两个学生出现在同一个社团,则将这两个集合合并起来,最后输出0号点所在集合的rank
yew1eb
·
2013-07-22 12:00
Password
Suspects
LA4126
AC自动机+状态压缩递推,通过这题主要学习了一下输出答案的方法,DP的话输出状态比较好办,因为最优决策一般只是一条路径,所以记录一下前驱可以用线性的复杂度输出路径,而递推确是多条路径的合集,输出路径比较麻烦,需要根据最终状态向前递推,并把经过的路径节点全部标记出来,由于递推状态设计本身是不会有重复的路径的,所以最后再从头dfs一遍访问过的节点并且记录,当递归深度合适时,输出记录即可。#includ
gyarenas
·
2013-05-24 20:00
POJ 1611 The
Suspects
链接:http://poj.org/problem?id=1611题意:N个人中如果某个人和另一个人接触了那么这两个人都有可能感染SARS,给出M组有接触的人群,问感染SARS的嫌疑者人数。(0号人一定是SARS感染嫌疑者)分析:并查集。每个集合有一个节点记录该集合的人数。 SourceCode:#include #definemaxn30010 intfather[maxn],num[max
HRHACMER
·
2013-05-11 20:00
POJ 1611 The
Suspects
【并查集入门】
TheSuspectsTimeLimit: 1000MS MemoryLimit: 20000KTotalSubmissions: 17149 Accepted: 8272DescriptionSevereacuterespiratorysyndrome(SARS),anatypicalpneumoniaofunknownaetiology,wasrecognizedasaglobalthreat
Cfreezhan
·
2013-04-06 21:00
POJ1611:The
Suspects
DescriptionSevereacuterespiratorysyndrome(SARS),anatypicalpneumoniaofunknownaetiology,wasrecognizedasaglobalthreatinmid-March2003.Tominimizetransmissiontoothers,thebeststrategyistoseparatethesuspectsf
libin56842
·
2013-03-20 23:00
ACM
poj
并查集
解题报告
Poj 1611 The
Suspects
TheSuspectsTimeLimit: 1000MS MemoryLimit: 20000KTotalSubmissions: 16690 Accepted: 8015DescriptionSevereacuterespiratorysyndrome(SARS),anatypicalpneumoniaofunknownaetiology,wasrecognizedasaglobalthreat
paradiserparadiser
·
2013-01-26 20:00
POJ The
Suspects
(基本的并查集)
没什么好说的,并查集的基本操作,都在注释里了#include #include #include #defineMAXN30005 usingnamespacestd; intparent[MAXN]; intrank[MAXN];//并查集的秩,根据题意,这里选用树的结点数。 voidMakeSet(intn) { for(inti=0;i=rank[py]) { parent[py]=px;
zhuang19922011
·
2012-12-16 10:00
zoj - 1789 - The
Suspects
题意:有n个学生,编号为0到n-1,m个群,给出每个群的学生,开始学生0被怀疑得了SARS,于是,人传人,被怀疑的学生所属群的所有学生都被怀疑,问共有几个学生被怀疑。题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=789——>>简单的并查集题目,将每个群的后一个学生与前一个学生judge,统计结点数输出即可。带路径压缩
SCNU_Jiechao
·
2012-12-11 23:00
POJ 1611 - The
Suspects
AdvancedDataStructures::DisjointSetDescription有n个学生,编号从0到n-1。学生们分成了几个团伙。而学生0是个“咸鱼饭”,因此和他一个团伙的人都是“咸鱼饭”。问有几个“咸鱼饭”。TypeAdvancedDataStructures:: DisjointSetAnalysis用并查集并一下,然后枚举下每个学生,查一下有多少人和学生0一个集合,就可以了。S
Ra_WinDing
·
2012-10-09 20:00
poj 1611 The
Suspects
点击打开链接poj1611思路:最简单的并查集应用分析:在输入的时候把在同一个集合里面的元素全部合并起来,然后最后在找有几个元素和0的根节点相同即可。代码:#include #include #include #include usingnamespacestd; constintMAXN=30010; intn,m; intnum[MAXN]; intfather[MAXN]; voidi
cgl1079743846
·
2012-09-24 11:00
poj 1611 The
Suspects
(并查集)
链接:http://poj.org/problem?id=1611题目:TheSuspectsTimeLimit: 1000MS MemoryLimit: 20000KTotalSubmissions: 15926 Accepted: 7622DescriptionSevereacuterespiratorysyndrome(SARS),anatypicalpneumoniaofunknownae
shuangde800
·
2012-09-23 00:00
POJ1611 The
Suspects
原题链接:http://poj.org/problem?id=1611 并查集。在每个group中,最开始的出发点是以该group中最小编号的学生为根的(这个是根据题意编号为0的学生是suspect来决定的),如果该group中有某个学生的父亲节点(或祖父节点)编号大于该group最小编号,则将最小编号union到上述的父亲节点(或祖父节点)上,那么在处理完成后,可以构造出一颗以编号0学生为
·
2012-09-06 11:00
poj
POJ1611The
Suspects
http://poj.org/problem?id=1611 import java.util.*; public class Main { Scanner scan=new Scanner(System.in); int[] arr=new int[30010],num=new int[30010]; public static void main(String[] args
believexkx
·
2012-08-10 08:00
java
并查集
【解题报告】 POJ 1611 The
Suspects
并查集基础 (一点自己的感悟)
题目连接:POJ1611最最基础的并查集题目,我就不说什么了。//POJ1611TheSuspects并查集 //初始化所有点的父节点初始为-1 //查找(找到两点的祖先),合并(合并两个点的祖先) //由于我们事先开了数组记录了祖先的所有所有结点数(办法是进来一个新的结点,则num[祖先]+=num[新节点]) // //还有我感觉并查集有点类似于皇帝->大臣->县令->师爷的关系 //一开始大
x314542916
·
2012-08-02 23:00
JVM "Out of swap space"错误常见的原因
occurs when your native heap is running out of memory not the java heap.The following could be the
suspects
xianqi_h
·
2012-08-01 15:00
swap
poj 1611 The
Suspects
//首次接触并查集,虽然是最基本的题目,但是不是很会做, //所以就看明白了并查集(看算法导论)和别人的代码之后,再自己写出来的! #include"iostream" usingnamespacestd; constintmaxsize=30010; intpa[maxsize];//每一个集合中元素的父节点 intranks[maxsize];//每一个集合中元素的秩 intnum[maxs
yzl_rex
·
2012-04-27 10:00
算法
zoj 1789||poj 1611 The
Suspects
(并查集,简单)
第一次写并查集题目,这个很纯-,-题目意思是要找出所有与0相关的数字的数目。写个集合把他们串起来就行了。首先根节点的父亲节点表示这个集合的数目,这样就不用重新开数组保存数目了。再做几个,并查集入门。#include//poj1161 #include #include usingnamespacestd; intN,M,K; intpre[30005]; voidUFset() { inti; f
cqlf__
·
2012-03-21 00:00
ini
POJ 1611 The
Suspects
TheSuspectsTimeLimit:1000MS MemoryLimit:20000KTotalSubmissions:13789 Accepted:6543DescriptionSevereacuterespiratorysyndrome(SARS),anatypicalpneumoniaofunknownaetiology,wasrecognizedasaglobalthreatinmi
ulquiorra0cifer
·
2012-03-10 10:00
zoj 1789 The
Suspects
/* zoj_1789并查集 并查集的简单应用,可以继续优化。 */ #include #include #include #include #defineN30002 usingnamespacestd; intfather[N],num[N],h[N]; voidinit(intn) { inti; for(i=0;ih[b]) father[b]=a; else { if(h[a]==h[
xsbailong
·
2012-02-04 15:00
优化
ini
POJ 1611:The
Suspects
并查集求解
题目URL:http://poj.org/problem?id=1611 我是用的并查集求解,另外用了添加集合元素时用了路径压缩,这样查找集合代表元素是可以时间更快。 这是我的AC代码,欢迎拍砖。 #include #include usingnamespacestd; constintMax=30000+10; intset[Max]; intsize[Max]; intr
bruce128
·
2011-12-21 10:00
url
System
IM
The
Suspects
POJ1611
TheSuspectsTimeLimit: 1000MS MemoryLimit: 20000KTotalSubmissions: 13311 Accepted: 6297DescriptionSevereacuterespiratorysyndrome(SARS),anatypicalpneumoniaofunknownaetiology,wasrecognizedasaglobalthreat
tiantangrenjian
·
2011-12-19 16:00
JOIN
算法
Integer
input
each
output
POJ-1611 The
Suspects
题目链接:http://poj.org/problem?id=1611题目大意:有一个学校,有N个学生,编号为0-N-1,现在0号学生感染了非典,凡是和0在一个社团的人就会感染,并且这些人如果还参加了别的社团,他所在的社团照样全部感染,求感染的人数。解题思路:并查集的变种,实质就是求0所在的强连通图的结点数目。这道题纠结在数据的输入上,他只是告诉你哪些学生是同一个社团的。这就需要处理一下,我的想法
niushuai666
·
2011-11-28 16:00
JOIN
delete
poj1611The
Suspects
好吧。。。并查集的题太好刷了#include #include usingnamespacestd; inta,b,t,n,m,x,ans,mid,sets[100000]; intfind(intx){ inty=x; if(sets[x]==x)returnx; else{ y=find(sets[x]); sets[x]=y; returny; } } intmain(){ while
bochuan007
·
2011-09-14 06:00
ini
poj1161 The
Suspects
并查集#include usingnamespacestd; #defineN30000 #defineG501 intp[N],group[N]; intmain() { intn,g; while(scanf("%d%d",&n,&g)==2) { if(n+g==0)break; inti,j,k; for(i=0;it)Min=t; } for(j=0;j
guogeer
·
2011-08-29 18:00
上一页
1
2
3
4
5
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他