随笔分类 - 图论——2-SAT
摘要:POJ3207 - Ikki's Story IV - Panda's Trickhttp://acm.pku.edu.cn/JudgeOnline/problem?id=3207POJ 3678 - Katu Puzzlehttp://acm.pku.edu.cn/JudgeOnline/problem?id=3678POJ 2723 - Get Luffy Outhttp://acm.pku.edu.cn/JudgeOnline/problem?id=2723POJ 3683 - Priest John's Busiest Dayhttp://acm.pku.edu
阅读全文
摘要:2-SAT水题,还wa了好几次,可见本菜更水。。。课件上都有讲解。。。渣代码:View Code #include <iostream>#include <cstring>#include <cstdio>#include <stack>using namespace std;const int N = 2012;const int M = 1000000;struct node { int to; int next;} g[M];int head[N], scc[N];int dfn[N], low[N];int t, ind, cnt;boo
阅读全文
摘要:重点是怎么建图,纠结了一天看2-SAT的资料...a 表示1, a'表示0,则:1、a and b = 1, a' -> a, b'-> b (a b 同时为1 )2、a and b = 0, a -> b', b -> a' (a b 不同时为1)3、a or b = 1, a' -> b, b' -> a (a b不同时为0)4、a or b = 0, a -> a', b -> b' (a b同时为0 同1)5、a xor b = 1, a -> b',
阅读全文
摘要:今天突然找到一道2-SAT的题,然后开始找各种资料,课件,最后还是看得云里雾里的。。。2-SAT算法解题过程:1.构图2.求图的极大强连通子图3.把每个子图收缩成单个节点,根据原图关系构造一个有向无环图4.判断是否有解,无解则输出(退出)5.对新图进行拓扑排序6.自底向上进行选择、删除7.输出今天(2/15)wy大牛给我解释是:其实就是把和取/析取式 变成蕴含式。话说偶的离散数学没学好,回头翻书去~~~
阅读全文

浙公网安备 33010602011771号