hdu1829 A Bug's Life(并查集)】的更多相关文章

开两个并查集.然后合并的时候要合并两次.这样在合并之前推断是否冲突,假设不冲突就进行合并,否则不须要继续合并. #include<cstdio> #include<cstdlib> #include<cstring> #include<algorithm> using namespace std; const int MAX=2000; int pre[2*MAX+5]; bool mark; void init(int n){ int i; for(i=1…
A Bug's Life                                                     Find them, Catch them 都是并查集构造的题,不久前MQL学长给我们拉过POJ上那道题,稍微复杂点,过了这么久竟然差不多忘完了,比赛的时候由队友在做这道题,我一直在看其他的题,在确定其他的题都不好做而且这个题好几个队都过了所以我们打算攻一攻这个题,只是依稀记得要用一个数组存与其对立的点,那么我们将与其对立的点都用并查集连起来,直接找是否有冲突就可以了…
A Bug's Life Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 28703   Accepted: 9350 Description Background  Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two different gender…
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 Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 28211   Accepted: 9177 Description Background Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two different genders…
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…
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 i…
Description 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…
题目链接:http://poj.org/problem?id=2492 A Bug's Life Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 39415   Accepted: 12835 Description Background Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes th…
一.题面 POJ2492 二.分析 并查集判断类别的题目感觉套路都差不多. 还是先判断在不在一个集合里,在一个集合里才能判断是否同类. 若不在一个集合里则需要将这两个点联系起来. 关于联系起来后关系的变化,画几个图后发现还是异或. 为什么用0表示同类,1表示异类?画几个图发现这样表示关系变换最简单. 三.AC代码 #include <cstdio> #include <iostream> #include <cstring> #include <fstream&g…