
2-sat
sepNINE
it is written
展开
-
poj 3683 Priest John's Busiest Day 2-sat
题意: 有n场婚礼,每场婚礼的属性有开始时间,结束时间,和祷告持续时间,每场婚礼的祷告必须安排在婚礼的开始或者结束,问是否存在一种安排使得每场婚礼的祷告互不重叠,有的话输出安排方案。 分析: n场婚礼,每场婚礼的祷告只能在开始或结束,2-sat问题,建图时采用互斥排定思想,即如果时间段i与时间段j互斥,则加i到非j、j到非i两条边。 代码: //poj 3683 //sep9 #incl原创 2014-12-15 17:25:09 · 644 阅读 · 0 评论 -
poj 2296 Map Labeler 2-sat
2-sat例题原创 2014-12-15 14:55:08 · 653 阅读 · 0 评论 -
poj 3678 Katu Puzzle 2-sat
题意: 给一堆布尔表达式,问是否存在解。 分析: 2-sat的入门题,只需判断是否有解,不要求输出解。 代码: //poj 3678 //sep9 #include #include using namespace std; const int maxN=10024; const int maxM=4200000; int e,n,m,t,ecnt; int head[maxN],i原创 2014-12-07 21:37:36 · 713 阅读 · 0 评论 -
poj 3207 Ikki's Story IV - Panda's Trick 2-sat
题意: 在一个圆上有n个点,m条边将他们相连,问是否有一种连发使没有两条线相交。 分析: 每条线要么在圆内,要么在圆外,2-sat问题。 代码: //poj 3207 //sep9 #include #include using namespace std; const int maxN=10024; const int maxM=4200000; int e,n,m,t,ecnt;原创 2014-12-08 13:58:51 · 714 阅读 · 0 评论 -
poj 3905 Perfect Election 2-sat
题意: 有n个候选人和m张选票,每张选票上有一种限制,问是否有一种让m张选票上的限制都满足的选举方案。 分析: 2-sat判断是否有解,不需输出解,标准化操作。 代码: //poj 3905 //sep9 #include #include using namespace std; const int maxN=2024; const int maxM=2200000; int e原创 2014-12-08 11:00:44 · 634 阅读 · 0 评论 -
poj 2723 Get Luffy Out 2-sat
2-sat算法例题原创 2014-12-08 18:38:51 · 789 阅读 · 0 评论 -
poj 3648 Wedding 2-sat
题意: 给n对夫妻安排座位,每对夫妻相对而坐,给出m对特殊关系,有特殊关系的人不能一起坐在新娘对面。 分析: 2-sat+输出解。 代码: #include #include #include #include using namespace std; const int maxN=1024; const int maxM=42000; int e,e1,n,m,t,ecnt;原创 2014-12-11 19:11:34 · 618 阅读 · 0 评论 -
poj 2749 Building roads 2-sat
2-sat例题原创 2014-12-14 16:29:49 · 752 阅读 · 0 评论