摘要: 2-satView Code 1 #include<iostream> 2 #include<vector> 3 #include<cstdio> 4 #include<cstring> 5 using namespace std; 6 const int MAX = 20010; 7 int n,m,T; 8 vector<int>mp[MAX]; 9 int st[MAX];10 int dfn[MAX],low[MAX];11 int top,btype,tdfn;//btype:连通块的个数12 int belong[MAX] 阅读全文
posted @ 2012-03-17 17:43 静静的等待_93 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 2-sat 只需要简单建图即可。View Code 1 #include<iostream> 2 #include<vector> 3 #include<cstring> 4 #include<cstdio> 5 #include<algorithm> 6 using namespace std; 7 const int maxn=20001; 8 vector<int>edge[maxn]; 9 int st[maxn];10 int dfn[maxn],low[maxn];11 int top,btype,tdfn;1 阅读全文
posted @ 2012-03-17 16:26 静静的等待_93 阅读(204) 评论(0) 推荐(0) 编辑
摘要: 新手学习2-sat算法,看了一个多小时,才看懂。然后类比着打代码,结果出来和网上的一样。。。不过这一题可以作为有向图缩点的模板,同时也可以比较清晰的理解2-sat的内涵,所以在这里仍然贴出来。View Code 1 #include<iostream> 2 #include<vector> 3 #include<cstring> 4 #include<cstdio> 5 #include<algorithm> 6 using namespace std; 7 const int maxn=20001; 8 vector<int& 阅读全文
posted @ 2012-03-17 15:48 静静的等待_93 阅读(418) 评论(0) 推荐(0) 编辑
摘要: 树形dp 结合01背包View Code 1 #include<cstdio> 2 #include<cstring> 3 #define max(a,b) a>b?a:b 4 const int INF = 1000000000; 5 const int maxn = 3010; 6 int head[maxn],dp[maxn][maxn],n,m; 7 int num[maxn]; 8 struct EDGE{ 9 int v,w,next;10 }edge[maxn];11 int tot;12 void add_edge(int s,int t,int 阅读全文
posted @ 2012-03-17 12:10 静静的等待_93 阅读(291) 评论(0) 推荐(0) 编辑