随笔分类 - 图论——2-Sat
摘要:题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4879代码:#include#include#include#include#includeusing namespace std;const int maxn = 550;struct Two_Sat{ int n; vector G[maxn*2]; bool mark[maxn*2]; int s[maxn*2],cnt; void init(int n) { this->n = n; memse...
阅读全文
摘要:题目链接:http://poj.org/problem?id=3678代码:#include#include#include#include#includeusing namespace std;const int maxn = 1050;struct Two_Sat{ int n; vector G[maxn*2]; bool mark[maxn*2]; int s[maxn*2],cnt; void init(int n) { this->n = n; memset(mark,0,sizeof(mark)); f...
阅读全文
摘要:这题的英语either...or....很蛋疼;m中,1:x与y至少一个出席;2:x出席,y随便,x不出席,y也不出席----这有个坑,可以推出y出席x也一定出席(这个关系必须要连上);3x与y至少一个不出席 4,x与y有且只有一个出席。对于k中的数据:我琢磨很久,关系在图上是建不了的,type为1时三个人至少有一个人要出席,则三个都不出席的情况是不允许的,dfs的时候判断一下就是了,同理type为2的情况。#include#include#include#include#include#include#includeusing namespace std;const int maxn = 1
阅读全文
摘要:#include#include#include#include#include#include#includeusing namespace std;const int maxn = 20050;const int INF = 0x3f3f3f;int n,m;char a[maxn][2];int b[maxn][2];struct TwoSat{ int n; vector G[maxn*2]; bool mark[2*maxn]; int s[2*maxn],cnt; void init(int n){ this->n = n; ...
阅读全文
摘要:题目链接:http://poj.org/problem?id=3207#include #include #include #include #include #include #include #define maxn 1050#define maxe 550 #define INF 0x3f3f3fusing namespace std;struct TwoSat{ int n; vector G[maxe*2]; bool mark[maxe*2]; int s[maxe*2],cnt; void init(int n){ this-...
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3062#include #include #include #include #include #include #include #define maxn 1250#define INF 0x3f3f3fusing namespace std;struct TwoSat{ int n; vector G[maxn*2]; bool mark[maxn*2]; int s[maxn*2],cnt; void init(int n){ this-...
阅读全文