poj2492_A Bug's Life_并查集】的更多相关文章

A Bug's Life Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 34947   Accepted: 11459 Description Background  Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two different gende…
                                                                                                A Bug's Life                  Background  Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two…
Background Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two different genders and that they only interact with bugs of the opposite gender. In his experiment, individual bugs and their in…
A Bug's Life 时间限制:1000 ms  |  内存限制:65535 KB 难度:4   描述 Background  Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two different genders and that they only interact with bugs of the opposite…
/* 目大意:输入一个数t,表示测试组数.然后每组第一行两个数字n,m,n表示有n只昆虫,编号从1—n,m表示下面要输入m行交配情况,每行两个整数,表示这两个编号的昆虫为异性,要交配. 要求统计交配过程中是否出现冲突,即是否有两个同性的昆虫发生交配. 思路:并查集 将同性的昆虫放入集合之中,如果输入的昆虫u, v同时出现在了集合中,那么 u,v就是同性的!发生了同性交配的可能! */ #include <string> #include <cstdio> #include <…
http://acm.hdu.edu.cn/showproblem.php?pid=1829 http://poj.org/problem?id=2492 臭虫有两种性别,并且只有异性相吸,给定n条臭虫(编号1-n)和m对关系,判断是否是出现同性恋的情况. 这题跟食物链的题类似,这里只有两种关系,关系是同性或者异性. 对于每只动物创建两个元素  同性或异性,并用这 2×n个元素建立并查集. 首先判断输入的x和y是否是一个组的.是就flag=1. 然后,如果x和y是一对,那么合并x和y+n,x+n…
题意:有n只虫子,每次给出一对互为异性的虫子的编号,输出是否存在冲突. 思路:用并查集,每次输入一对虫子后就先判定一下.如果两者父亲相同,则说明关系已确定,再看性别是否相同,如果相同则有冲突.否则就将两只虫子并入一个集合. 而性别则是用一个gender数组来维护,每个虫子的gender的值为0或者1. 0表示该虫子的性别与父亲结点的性别相同. 1表示该虫子的性别与父亲结点的性别不同. 这题和poj1703本质上是一样的.1703的题解请点传送门. 另外还有一个疑惑,本题输入量巨大,我用输入加速后…
A Bug's Life Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 34678   Accepted: 11339 Description Background Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two different gender…
A Bug's Life Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 30130   Accepted: 9869 Description Background Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two different genders…
English preparation: falsify     伪造:篡改:歪曲:证明...虚假 the sexual behavior of a rare species of bugs. 一种稀有昆虫的性行为. the number of scenarios 场景数量 consecutively 连续地 趣语: 这个时代,是个雷人的时代.凤姐的出现,让我们对自己的审美观产生了怀疑:著姐的降临,使我们对自己的性取向做出了更正.而如今,bug们被同性恋了,这直接就是商人们为了扩大HS产业的炒作…