poj 2723】的更多相关文章

Get Luffy Out Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 8851   Accepted: 3441 Description Ratish is a young man who always dreams of being a hero. One day his friend Luffy was caught by Pirate Arlong. Ratish set off at once to Arlo…
HDU 1816, POJ 2723 Get Luffy Out pid=1816" target="_blank" style="">题目链接 题意:N串钥匙.每串2把,仅仅能选一把.然后有n个大门,每一个门有两个锁,开了一个就能通过,问选一些钥匙,最多能通过多少个门 思路:二分通过个数.然后对于钥匙建边至少一个不选,门建边至少一个选,然后2-sat搞一下就可以. 一開始是按每串钥匙为1个结点,但是后面发现数据有可能一把钥匙,出如今不同串(真是不合…
Get Luffy Out Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7295   Accepted: 2778 Description Ratish is a young man who always dreams of being a hero. One day his friend Luffy was caught by Pirate Arlong. Ratish set off at once to Arlo…
思路:二分枚举能开的门的数量,将每次枚举转换成2-SAT问题.这里存在的矛盾是假设有门上a,b两个锁,a锁对应于1号钥匙,而一号钥匙的配对是2号钥匙,b锁对应于3号钥匙,3号的配对是4号钥匙.那么2号和4号就不能同时被选,否则有a,b锁的门就开不了. #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<cmath> #define M…
Description Ratish is a young man who always dreams of being a hero. One day his friend Luffy was caught by Pirate Arlong. Ratish set off at once to Arlong's island. When he got there, he found the secret place where his friend was kept, but he could…
题目链接 给n个钥匙对, 每个钥匙对里有两个钥匙, 并且只能选择一个. 有m扇门, 每个门上有两个锁, 只要打开其中一个就可以通往下一扇门. 问你最多可以打开多少个门. 对于每个钥匙对, 如果选择了其中一个钥匙, 那么另一个就不能选. 所以加边(a, b'), (b, a'). 对于每个门, 如果不打开其中一个锁, 那么另一个锁就一定要打开. 所以加边(a', b), (b', a). 然后二分判断就可以了. #include <iostream> #include <vector>…
二分答案 + 2-SAT验证 #include<cstdio> #include<cstring> #include<cmath> #include<stack> #include<queue> #include<algorithm> using namespace std; +; int N,M; stack<int>S; vector<int>G[maxn]; vector<int>FG[max…
题意:给出n对钥匙,每对钥匙只能选其中一个,在给出每层门需要的两个钥匙,只要一个钥匙就能开门,问最多能到哪层. 思路:了解了2-SAT判定的问题之后主要就是建图的问题了,这里建图就是对于2*n个钥匙,分别分成a和a'两组,即选了比如a,b一组钥匙,选择了a则必须选择b',那么进行连边,而对于每层门,若该门能开,且选择了a',则b肯定需要选,那么a'和b连边.最后就是判定了,同样的 若a与a'在同一个连通分量中,表示无解.这题需要利用二分枚举答案m. 代码: #include<iostream>…
两个钥匙a,b是一对,隐含矛盾a->!b.b->!a 一个门上的两个钥匙a,b,隐含矛盾!a->b,!b->a(看数据不大,我是直接枚举水的,要打开当前门,没选a的话就一定要选b打开.没选b的话,就一定要选a打开) #include<iostream> #include<cstdio> #include<cstring> #include<vector> #include<algorithm> #include<cm…
Description Ratish is a young man who always dreams of being a hero. One day his friend Luffy was caught by Pirate Arlong. Ratish set off at once to Arlong's island. When he got there, he found the secret place where his friend was kept, but he could…