随笔分类 - 2-SAT
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=37172-sat版题对半径R进行二分,将二分得到的R用2-sat判,如果2R 3 #include 4 #include 5 #include 6 #includ...
阅读全文
摘要:http://poj.org/problem?id=2296很好的一道2-SAT题取上为1,取下为0两个新规则:a = 0: 这个等价于加边!a->aa = 1: 这个等价于加边a->!a当二者y差值 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 #include 13 #include 14 #include 15 #include 16 #include 17 using namespace std; 18 type.
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1814裸的2-SAT版题(模板得到的方案是按字典序得到的)(调试调到死。。。)直接按照输入按AND=1的规则加边,然后跑2-SAT输出即可2-SAT原理详见kuangbin大神的博客:http://www.cnblogs.com/kuangbin/archive/2012/10/05/2712429.html 1 //#pragma comment(linker, "/STACK:102400000,102400000") 2 #include 3 #include 4 #include
阅读全文
摘要:http://poj.org/problem?id=3207两条边不能相交->两条边仅能存1->两条边XOR=1明显的2-SAT如果扫描到两条边可能相交就按XOR=1的规则加边,然后用2-SAT判可行性即可可能相交条件:1 bool check(int i,int j)2 {3 return (node[i].x 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 #include 13 #include 14 #in...
阅读全文
摘要:1 /** 2 *2-SAT模板,Modified Edition of LRJ 3 *输入:按照法则添加边(参数为2*i或者2*i+1) 4 *运行:先init(n),再add(),再solve() 5 *输出:mark[](1表示选中),solve()(是否有解) 6 */ 7 const int maxn = 0; 8 struct TwoSAT 9 { 10 int n; 11 vector G[maxn*2]; 12 bool mark[maxn*2]; 13 int S[maxn*2], c; 14 15 bool df...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3622对半径进行二分,如果冲突则加入边(按照X AND Y == 0的法则插入边),再2-SAT即可。 1 //#pragma comment(linker, "/STACK:102400000,102400000") 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 #include 13 #include 1
阅读全文

浙公网安备 33010602011771号