
图论-2sat
文章平均质量分 84
JeraKrs
本人目前就职于百度商业研发部,有需要内推的朋友简历可发我邮箱 jerakrs@qq.com
展开
-
uva 11294 - Wedding(2 sat)
题目链接:uva 11294 - Weddingh为true,w为false,每对超过架的人就是一对关系。做2sat#include #include #include #include using namespace std;const int maxn = 205;struct TwoSAT { int n; bool mark[maxn * 2];原创 2015-09-07 22:46:53 · 1120 阅读 · 1 评论 -
uva 1146 - Now or later(二分+2sat)
题目链接:uva 1146 - Now or later二分答案,然后间隔小于当前值的即为一组矛盾关系,对所有关系做2sat。#include #include #include #include #include using namespace std;const int maxn = 2005;int N, T[maxn][2];struct Tw原创 2015-09-07 22:59:47 · 559 阅读 · 0 评论 -
uva 1466 - String Phone(2SAT)
题目链接:uva 1466 - String Phone对于每个位置而言,只有对定角的两个位置可能共存,所有枚举每个位置后可以用dfs预处理出每个地方是哪两个角有可能,然后做2SAT。#include #include #include #include #include using namespace std;const int maxn = 3005;c原创 2015-09-12 22:20:27 · 782 阅读 · 0 评论 -
uva 1514 - Piece it together(2SAT)
题目链接:uva 1514 - Piece it together建图做2SAT判定,详细请看代码注释。#include #include #include #include using namespace std;typedef pair pii;const int maxn = 1e6 + 5;const int maxm = 1005;const i原创 2015-09-12 22:19:23 · 771 阅读 · 0 评论 -
uva 10319 - Manhattan(2 sat)
题目链接:uva 10319 - Manhattan对于每对点,(r1&c2) || (r2&c1),根据分配率拆成4条关系,然后做一遍2 sat。#include #include #include #include using namespace std;const int maxn = 1005;struct TwoSAT { int n, c, S原创 2015-09-07 22:20:54 · 689 阅读 · 0 评论 -
uva 12273 - Palindromic DNA(4SAT)
题目链接:uva 12273 - Palindromic DNA每个位置有4个值,对应ATCG,然后对应建立限制关系,初始要将每个位置对应变换两次的位置置为false。#include #include #include #include using namespace std;const int maxn = 1e4 + 5;struct TwoSAT {原创 2015-09-11 21:30:22 · 665 阅读 · 0 评论 -
uva 11930 - Rectangles(几何+2SAT)
题目链接:uva 11930 - Rectangles#include #include #include #include using namespace std;typedef long long ll;const int maxn = 1005;struct TwoSAT { int n, s[maxn * 2], c; bool mark[maxn * 2原创 2015-09-11 21:26:19 · 696 阅读 · 0 评论 -
uva 1086 - The Ministers' Major Mess(2 SAT)
题目链接:uva 1086 - The Ministers' Major Mess枚举每个点,判断是否y,n都存在解,如果都存在即为?, 最后做一遍2SAT即可。#include #include #include #include using namespace std;const int maxn = 105;struct TwoSAT { int n原创 2015-09-10 22:53:33 · 782 阅读 · 0 评论 -
uva 1391 - Astronauts(2sat)
题目链接:uva 1391 - Astronauts#include #include #include #include #include using namespace std;const int maxn = 100005;struct TwoSAT { int n; bool mark[maxn * 2]; vector G[maxn * 2]; in原创 2015-09-07 23:19:06 · 868 阅读 · 0 评论 -
hdu 4115 Eliminate the Conflict(2SAT)
题目链接:hdu 4115 Eliminate the Conflict代码#include <cstdio>#include <cstring>#include <vector>#include <algorithm>using namespace std;const int maxn = 10005;struct TwoSAT { int n, s[maxn<<1], c;原创 2015-11-12 15:10:27 · 494 阅读 · 0 评论