码迷,mamicode.com
首页 >  
搜索关键字:种类并查集    ( 90个结果
POJ 1182 食物链 (种类并查集)
食物链 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 47729   Accepted: 13895 Description 动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。  现有N个动物,以1-N编号。每...
分类:其他好文   时间:2015-01-24 17:28:07    阅读次数:185
poj-1182 种类并查集
转:用0  1   2 分别表示A B C的关系。 0吃1,1吃2,2吃0. 注意这个编号都是以根结点为参照的,不是绝对的。 开一个val数组,一开始这个数组为0,所有的点都是独立的,不是相连的,没有关系。 慢慢加入点之后,把有关系的合并在一起,并且编号的相对大小确定一个集合中的关系。 #include #include #include ...
分类:其他好文   时间:2015-01-19 17:21:14    阅读次数:193
2-XOR-SAT (种类并查集)
写了那么多模拟题这题算是最难的了QAQ好神,,,我于是补了一下并查集。。并查集很神。。。。。。orz种类并查集。。。orz对于维护sat,我们可以这样想:如果x和y的xor是true,那么x和y肯定不一样,那么我们有s[x]=s[y]^1否则s[x]=s[y]我们需要维护的是一系列的x和y之间的关系...
分类:其他好文   时间:2014-10-29 20:59:45    阅读次数:161
ACdream 1056 Bad Horse (种类并查集)
Bad Horse Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) SubmitStatus Problem Description As the leader of the Evil League of Evil, Bad Horse has a lot of ...
分类:其他好文   时间:2014-10-05 18:40:59    阅读次数:167
POJ 1988 Cube Stacking (种类并查集)
题目地址:POJ 1988       这道题的查找合并的方法都能想的到,就是一点没想到,我一直天真的以为查询的时候,输入后能马上输出,这样的话在合并的时候就要所有的结点值都要算出来,但是经过路径压缩之后,没办法全部都处理到,如果不压缩妥妥的TLE。。于是看了看网上的题解。才发现自己是多么的天真(ben,四声)。。在查询的时候只要找一次跟就可以了。。这样不需查询的也就没必要处理出来。反而更省时。...
分类:其他好文   时间:2014-10-02 00:02:01    阅读次数:279
POJ 1703 Find them, Catch them(种类并查集)
题目地址:POJ 1703 种类并查集水题。 代码如下: #include #include #include #include #include #include #include #include #include #include #include using namespace std; int bin[600000], rank[600000]; int f...
分类:其他好文   时间:2014-10-01 21:37:32    阅读次数:232
POJ 1182 食物链(种类并查集)
题目地址:POJ 1182 一道很经典的种类并查集的题目。利用互相之间的关系来进行权值的维护。 代码如下: #include #include #include #include #include #include #include #include #include #include #include using namespace std; int bin[600...
分类:其他好文   时间:2014-10-01 20:57:01    阅读次数:163
HDU 1829 && POJ 2492 A Bug's Life(种类并查集)
题目地址:HDU 1829     POJ 2492 这个题可以用两种方法做,第一眼看完题是觉得用dfs染色判断二分图。然后又写的刚学的种类并查集。原来并查集可以这样用,真是神奇。。 dfs染色代码: #include #include #include #include #include #include #include #include #include #inclu...
分类:其他好文   时间:2014-10-01 19:51:01    阅读次数:158
poj1703--Find them, Catch them
题意:一个城市n个犯罪嫌疑人,编号1-n,每次输入D x y表示x y属于同一帮派,A x y询问x y是否同一帮派或者不确定。带权、种类并查集裸题,图片质量不好还请见谅。。oet[fx] = (oet[y]-oet[x]+d+2)%2 根据箭头关系就可以得出这个式子了,,加2是防止出现负值#in....
分类:其他好文   时间:2014-09-20 01:04:16    阅读次数:277
POJ 1703 Find them, Catch them
题目链接:http://poj.org/problem?id=1703思路:种类并查集。 并设置一个opp数组,opp[i]代表与i相对立的。代码: #include #include using namespace std;int c,d;int t1,t2;int opp[100005];in....
分类:其他好文   时间:2014-09-19 15:27:05    阅读次数:182
90条   上一页 1 ... 6 7 8 9 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!