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
2492
[POJ
2492
]A Bug's Life[并查集]
题目链接:[POJ
2492
]ABug'sLife[并查集]题意分析:给出n个虫子,和m个虫子间的关系a,b,代表a喜欢b。问:在给出的关系中,是否存在同性恋的虫子呢?
CatGlory
·
2015-09-07 21:00
并查集
HDU 5285 wyh2000 and pupil
分析:这题和POJ
2492
差不多,所以我用的是并查集,可以把题意理解为有很多人,要分成两个帮派,每个帮派至少有1个人,输入n,m分别代表n个人,和m对有冲突的人,有冲突的不能在一个帮派里,要尽可能的使第一个帮派的人多一些
ZengAMing
·
2015-08-20 10:00
ACM
【暑假专题训练#数据结构】
HDU
2492
Pingpong(树状数组+逆序数2008RegionalBeijing)【题目链接】:clickhere~~【题目大意】每一个人都有一个实力值ranking,顺序就是他的位置,要求最多的比赛
u013050857
·
2015-08-10 16:00
数据结构
专题训练
poj
2492
&&hdu1829
链接:点击打开链接题意:给出一个T代表几组数据,给出一个m一个n,代表人的编号由1~m,n条命令,每条命令由两个数值组成,代表这两个人性别不同,问所有命令是否符合逻辑例如:给出数据为1||33||12||13||23,表示1,2性别不同,1,3性别不同,因此可以推断出2,3性别一定相同,但是由给出了2,3因此不符合逻辑代码:#include #include #include usingnames
stay_accept
·
2015-08-10 11:00
POJ
2492
A Bug's Life 并查集
#include #include usingnamespacestd; intf[3000],relation[3000]; voidinit(intn) { for(inti=0;i<=n;i++) { f[i]=i; relation[i]=1; } } intfind(intx) { if(x==f[x])returnx; inttem=f[x]; f[x]=find(f[x]); rel
zhou_yujia
·
2015-08-10 09:00
算法
并查集
Poj
2492
A Bug's Life
Poj
2492
的传送门题目大意:输入n个bug,bug之间有interaction,当前假设异性之间才interaction,但是需要验证,给定这些interaction对,判定是否满足假设,如果相同则有同性恋
qingshui23
·
2015-08-09 20:00
并查集
POJ
2492
A Bug's Life(虫虫危机)
[poj
2492
](http://poj.org/problem?
PNAN222
·
2015-08-09 18:00
bug
poj
并查集
Hdu
2492
树状数组 Ping pong
1#include 2#include 3#include 4#defineMAXN100005 5#defineM20005 6typedef__int64LL; 7usingnamespacestd; 8LLn,max_num; 9LLs[M],a[M],b[M],c[MAXN]; 10LLlowbit(LLx){ 11returnx&(-x); 12} 13LLsum
fancy_boy
·
2015-08-05 15:00
带权并查集 POJ1988 POJ
2492
单纯的并查集很简单,带权并查集还能解决更多的问题,才更好玩,来个题热身。对于下面的知识,现在就当你已经熟练掌握了递归和并查集的路径压缩。POJ1988:题目链接 http://poj.org/problem?id=1988题目大意:有N(N #include #include usingnamespacestd; constintmaxn=30000+10; intsum[maxn],par[m
u013068502
·
2015-08-04 18:00
poj
POJ
2492
A Bug's Life(扩展并查集)
#pragmawarning(disable:4996) #include #include #include #include usingnamespacestd; //扩展并查集 intfa[2001],relation[2001]; //同性为0,异性为1 intfind(intx){ if(x==fa[x])returnx; inttmp=fa[x]; fa[x]=find(tmp);
acraz
·
2015-08-03 16:00
POJ
2492
A Bug's Life
id=
2492
J - A Bug's Life Time Limit:10000MS Memory Limit:65536KB
·
2015-07-25 08:00
life
A Bug's Life - poj
2492
Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status Description Background Professor Hopper is researchi
·
2015-07-24 20:00
life
J - A Bug's Life - poj
2492
这个题目很有意思啊,有一些bug生物(肯定是程序员养的),有人观察他们的生活习惯,观察他们之间是否有同性恋关系,比如ab发生关系,bc发生关系,ab发生关系。。。产生了同性恋了,你需要判断一下这种关系是不是存在。 分析,这个跟食物链没什么区别,而且条件还少了不少,规定同性关系是0, 异性关系是1 /////////////////////////////////////////////
·
2015-07-23 10:00
life
POJ
2492
A Bug's Life
分析:给你多只虫子的关系,判断有没有gay,一开始初始化他们都没有对象relative[i]=0;如果a,b都没有对象,那么a的对象是b,b的对象是a;如果a有,b没有,b的对象就是a,把b加入到a的对象的集合中;b有,a没有同理;如果a,b都有对象,就把他们加入到各自的对象集中,一只虫子的第一个对象为老大,后来加进来的都要归他管。#include intflag,root[2005],relat
ZengAMing
·
2015-07-13 20:00
ACM
poj
poj 并查集 -
2492
A Bug's Life
并查集题目,并的意思就是将两个不同类别的集合合并到一起,类似于两棵树合并;查的意思就是找到这个点所属集合的根节点。基本上并查集题目都是在大体架构上面加一些东西即可。并查集代码模板在这里点击打开链接这道题目和poj1703很相似,bug之间只存在两种状态,男1和女0,所以两个被判断是同性的相恋就可疑了(德国人还挺好玩)。在这里这里在并查集模板里加入一个sex数组,用来说明这一个节点的bug是属于男还
u010006643
·
2015-04-24 20:00
poj
并查集
树状数组 POJ
2492
Ping Pong
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=12089题意:按顺序给定一些人和能量值。问按照顺序选人,中间人能量值在两边人能量值的中间,问最多有多少种选法思路:一次AC有木有!其实是照着书上题解的思路打的。设c[i]为某a[i]处左边能量值比他小的人数和,d[i]为右边能量值比他大的人数和,然后一个简单公式即可。
beihai2013
·
2015-04-17 10:00
【BZOJ3038】【Codevs
2492
】上帝造题的七分钟2
喜闻乐见双倍经验
2492
上帝造题的七分钟2时间限制:1s空间限制:64000KB题目等级:大师Master题目描述DescriptionXLk觉得《上帝造题的七分钟》不太过瘾,于是有了第二部。
CreationAugust
·
2015-04-10 07:00
线段树
poj
2492
poj1182种类并查集
这两道题感觉有点难,自己琢磨了好一阵子也没什么结果最后还得大神的思维啊!! poj1182点击打开链接分析:这个题大意说的非常清楚了,就是求出假话的个数,题目中给的假话要求有三个 ① 当前的话与前面的某些真的话冲突,是假话; ②当前的话中X或Y比N大,是假话;③当前的话表示X吃X,是假话。 ②和③很好判断了,最难的就是假话条件①啦!! 题中说有三种动物A,B,C; A-->B-->C-->A
wangdan11111
·
2015-02-16 22:00
并查集
poj1182
poj2492
POJ
2492
---A Bug's Life
ABug'sLifeTimeLimit:10000MS MemoryLimit:65536KTotalSubmissions:29209 Accepted:9528DescriptionBackgroundProfessorHopperisresearchingthesexualbehaviorofararespeciesofbugs.Heassumesthattheyfeaturetwodiff
Guard_Mine
·
2015-01-22 13:00
poj
POJ1703 POJ
2492
并查集
并查集应用:POJ1703 Findthem,Catchthem题目大意:一个城市有两个帮派(我猜gngs应该差不多就这个意思吧,,不用在意这些细节啦),对于每组输入,Dab表示a和b属于不同的帮派,Aab问你a和b是否在同一个帮派,对于每次询问,输出相应的结果即可。分析:说白了,这题就是简化版的食物链。和食物链的思想一样,我们用a和a+N表示a在哪个集合,这样,对于输入的Dab,我们只需合并
AC_Gibson
·
2015-01-05 19:00
树状数组+逆序数与顺序数——HDU
2492
对应HDU题目:点击打开链接PingpongTimeLimit:3000MS MemoryLimit:0KB 64bitIOFormat:%lld&%lluSubmit StatusDescriptionN(3N20000) pingpongplayerslivealongawest-eaststreet(considerthestreetasalinesegment).Eachp
u013351484
·
2014-12-23 14:00
POJ
2492
A Bug's Life (并查集)
本文出自:http://blog.csdn.net/svitter题意:给出昆虫编号,看昆虫能否交配,如果出现同性交配或者自我交配的情况,则出现BUG。输入输出分析:1.输入输出数据:input:2 33 12 23 13 42 12 34output:Scenario#1: Suspiciousbugsfound! Scenario#2: Nosuspiciousbugsfound!第一行给出
svtter
·
2014-10-17 23:00
算法
poj
并查集
POJ
2492
A Bug's Life (并查集)
本文出自:http://blog.csdn.net/svitter题意:给出昆虫编号,看昆虫能否交配,如果出现同性交配或者自我交配的情况,则出现BUG。输入输出分析:1.输入输出数据:input:2 33 12 23 13 42 12 34output:Scenario#1: Suspiciousbugsfound! Scenario#2: Nosuspiciousbugsfound!第一行给出
svtter
·
2014-10-17 23:00
算法
poj
并查集
poj
2492
--A Bug's Life(并查集变形)
ABug'sLifeTimeLimit: 10000MS MemoryLimit: 65536KTotalSubmissions: 28703 Accepted: 9350DescriptionBackground ProfessorHopperisresearchingthesexualbehaviorofararespeciesofbugs.Heassumesthattheyfeaturetw
u013015642
·
2014-10-16 21:00
POJ 3928 & HDU
2492
Ping pong(树状数组求逆序数)
pid=
2492
DescriptionN(3 #include #include #include usingnamespacestd; constintmaxn=100017; intn; inta[
u012860063
·
2014-10-16 21:00
poj
HDU
HDU 1829 && POJ
2492
A Bug's Life(种类并查集)
题目地址:HDU1829 POJ
2492
这个题可以用两种方法做,第一眼看完题是觉得用dfs染色判断二分图。然后又写的刚学的种类并查集。原来并查集可以这样用,真是神奇。。
u013013910
·
2014-10-01 18:00
编程
算法
C语言
ACM
并查集
poj
2492
并查集(虫子交配,同性恋?)
题意:一组昆虫性别有公有母,现给出一组交配信息,问是否有同性恋发生。思路:1、并查集。维护一个性别数组。关键代码见注释!2、二分图着色判断是否为二分图。也就是在交配的虫子之间连边,判断每一个连通分量是否为二分图。#include #include #defineN2005 intf[N],gender[N]; intc,n,m,T; intfind(intx){ inttemp=f[x]; if(
dumeichen
·
2014-09-23 10:00
POJ
2492
A Bug's Life
id=
2492
ABug'sLifeTimeLimit: 10000MS MemoryLimit: 65536KTotalSubmissions: 28494 Accepted: 9286DescriptionBackground
u012560612
·
2014-09-11 18:00
Algorithm
ACM
poj
并查集
向量并查集
POJ
2492
——A Bug's Life
DescriptionBackgroundProfessorHopperisresearchingthesexualbehaviorofararespeciesofbugs.Heassumesthattheyfeaturetwodifferentgendersandthattheyonlyinteractwithbugsoftheoppositegender.Inhisexperiment,ind
Guard_Mine
·
2014-09-03 13:00
hdu
2492
Ping pong (树状数组)
PingpongTimeLimit:2000/1000MS(Java/Others) MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):3964 AcceptedSubmission(s):1467ProblemDescriptionN(3 #include #include #include usingnamespaces
caduca
·
2014-08-26 20:00
Algorithm
反汇编学习
(转:http://www.kuqin.com/assemble/20071122/
2492
.html)汇编语言和CPU以及内存,端口等硬件知识是连在一起的.这也是为什么汇编语言没有通用性的原因.下面简单讲讲基本知识
lovewubo
·
2014-07-18 21:00
Angular $Watch
http://www.bennadel.com/blog/
2492
-what-a-select-watch-teaches-me-about-ngmodel-and-angularjs.htm
lglgsy456
·
2014-06-19 16:00
【树状数组】HDOJ
2492
Ping pong
简单的树状数组。枚举每一个裁判,ans=left_min[i]*right_max[i]+left_max[i]*right_min[i]。写的时候直接把n当成树状数组的最大值了,找了半天的错找吐血了。。。。。贴上代码。#include #include #include #include #include #include #include #include #include #include
blankcqk
·
2014-06-19 10:00
POJ
2492
(根的移动)
#include#includeusingnamespacestd;intf[2010];intr[2010];intn,m;boolflag;intfind_Set(intx){ inttemp; if(x==f[x]){ returnx; } temp=f[x]; f[x]=find_Set(temp); r[x]=(r[x]+r[temp])%2; //保持r[x]相对于
u013570474
·
2014-06-19 05:00
POJ
2492
#include#include#includeusingnamespacestd;intrel[2010];intfa[2010];intfind(inta){ if(a!=fa[a]) fa[a]=find(a); returnfa[a];}voidfan(inta,intb){ intpa=find(a); intpb=find(b); if(pb!=pa) fa[pa]
u013570474
·
2014-06-18 22:00
POJ
2492
(种类并查集)
id=
2492
ABug'sLifeTimeLimit: 10000MS MemoryLimit: 65536KTotalSubmissions: 27388 Accepted: 8907DescriptionBackground
u013790563
·
2014-06-12 15:00
Wikioi
2492
树状数组+并查集(单点更新区间查询)
刚开始做的时候用线段树做的,然后就跳进坑里了……因为要开方,所以区间的值都得全部变,然后想用lazy标记的,但是发现用不了,单点更新这个用不了,然后就不用了,就T了。然后实在不行了,看了别人的题解,原来是用树状数组+并查集的方法,唉……没想到啊!因为开方之后多次那个数就会变成1了,所以是1的时候开方下去就没用了。树状数组更新的时候就把其更新的差更新即可,太机智了这题……昨天做了,然后出错找了好久都
u011466175
·
2014-05-09 14:00
poj
2492
A Bug's Life(带权并查集)
题目:poj
2492
ABug'sLife(带权并查集)题目大意:一个博士研究虫子里面是否有同性恋,给出多次虫子的交配关系。
u012997373
·
2014-04-23 09:00
POJ
2492
A Bug's Life
id=
2492
题意:这竟然是一道同性恋的题OMG,给你N条BUG,然后给出M条,a和b是异性,问有无同性恋详细题解:种类并查集与父节点同性则为0,异性为1#include #defineN2200 intF
fjy4328286
·
2014-04-22 19:00
hdu
2492
Ping pong(线段树+思维)
PingpongTimeLimit:2000/1000MS(Java/Others) MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):3560 AcceptedSubmission(s):1312ProblemDescriptionN(3 #include #include usingnamespacestd; const
y5885922
·
2014-04-22 13:00
c
算法
ACM
POJ
2492
A Bug's Life
手残残一题,脑残毁一生系列~~明明跟POJ1703是一样的思路啊呀喂,昨天晚上调到死也调不出来啊呀喂~~今早晨才发现初始化函数放错位置了~~不能再这样了啊~~题目大意:有N个虫子,只有异性交配才是正常的,但我们不知道哪个虫子的性别是什么。给出M个交配事件,问能否发现同性交配的事件。解题思路:跟1703一样,种类并查集。只不过上一次是帮派,这一次是性别~下面是代码:#include intn,q;
lin375691011
·
2014-03-29 08:00
poj
并查集
刷题
linux下使用pmap和ldd查看进程调用了什么lib
pmap命令使用方法:pmap进程pid如下是查看nginx调用了哪些lib#pmap
2492
2492
:nginx:masterprocess/usr/local/nginx-1.4.1/sbin/nginx
小运
·
2014-03-23 01:00
pmap
ldd
查看lib
查看调用了什么lib
查看调用了什么库文件
poj
2492
之树状数组
PingpongTimeLimit:2000/1000MS(Java/Others) MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):3427 AcceptedSubmission(s):1264ProblemDescriptionN(3 #include #include #include #include #inclu
xingyeyongheng
·
2014-03-12 19:00
POJ
2492
A Bug's Life(路径压缩并查集)
POJ
2492
ABug'sLife(路径压缩并查集)http://poj.org/problem?id=
2492
题意: 有N个虫子和M次两个不同虫子的交流行为。
u013480600
·
2014-03-12 12:00
ACM
poj
2492
A Bug's Life
先上题目:4:ABug'sLife查看提交统计提问总时间限制:10000ms内存限制:65536kB描述BackgroundProfessorHopperisresearchingthesexualbehaviorofararespeciesofbugs.Heassumesthattheyfeaturetwodifferentgendersandthattheyonlyinteractwithbu
mach7
·
2014-03-10 17:00
向量
poj2492
带关系的并查集
并查集拓展
并查集应用
HDU
2492
Ping pong
题目链接:HDU
2492
Pingpong树状数组。把技能值看成树状数组中的单元,所以要注意add函数中while循环的条件,是小于M而不是N,M是技能值的范围,N是人数。
fobdddf
·
2014-03-08 21:00
POJ
2492
和食物链类似,需要计算集合之间的关系。这里明确一点即可,就是根节点的初始值是都相同,为0。只要在路径压缩和合并的时候注意即可。#include #include #include usingnamespacestd; #defineLLEN2005 intc,g; intp[LLEN],f[LLEN]; voidinit(){ for(inti=0;i<=c+5;i++){ p[i]=i;
X_White
·
2013-12-18 11:00
并查集 题集
基础:HDU 1213 1232 1233 1879POJ 2236 1161 2524 3047强化训练:POJ1182 食物链 并查集经典(向量法)POJ
2492
并查集+可能涉及到DPS+二分图匹配
u012861385
·
2013-11-17 12:00
poj
2492
- A Bug's Life(并查集)
题意:针对实验结果来验证教授的假设是否成立。每行给出一个a和b表示a和b是异性的,让我们来验证这种假设对于所有的实验结果是否会出现矛盾。思路:并查集,用一个数组来维护集合中每个元素与头结点是否同姓,同姓标为0,异性标为1。代码如下:constintM=2005; intp[M],flag[M]; voidinit(intn) { memset(flag,0,sizeof(flag)); for(i
shankeliupo
·
2013-10-22 13:00
HDU
2492
Ping pong
pid=
2492
LRJ书上例题题意:给出1~n个选手的skillrank,如果两个选手要进行比赛,两个选手中间必须有一个裁判,这个裁判的skillrank介乎富这两个选手之间,问能举
fjy4328286
·
2013-10-22 09:00
树状数组
上一页
1
2
3
4
5
6
下一页
按字母分类:
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
其他