2013年4月17日

hdu 3062 Party 2-SAT入门

摘要: PartyTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2822Accepted Submission(s): 878Problem Description有n对夫妻被邀请参加一个聚会,因为场地的问题,每对夫妻中只有1人可以列席。在2n 个人中,某些人之间有着很大的矛盾(当然夫妻之间是没有矛盾的),有矛盾的2个人是不会同时出现在聚会上的。有没有可能会有n 个人同时列席?Inputn: 表示有n对夫妻被邀请 (n<= 1000)m: 表示 阅读全文

posted @ 2013-04-17 21:12 电子幼体 阅读(138) 评论(0) 推荐(0) 编辑

2-SAT模板

摘要: #include <iostream> #include <cstdio> #include <cstring> using namespace std; const int maxn=4444; const int maxm=1111111; struct EDGE{ int to; int w; int next; }edges[maxm]; int head[maxn]; int edge,node; int lowlink[maxn],pre[maxn],sccno[maxn],stk[maxn],top,dfs_clock,scc_cnt; voi 阅读全文

posted @ 2013-04-17 21:11 电子幼体 阅读(116) 评论(0) 推荐(0) 编辑

SCC的Kosaraju算法模板

摘要: //-----Kosaraju vector<int>G[maxn],G2[maxn]; vector<int>S; int vis[maxn],sccno[maxn],scc_cnt; void dfs1(int u) { if (vis[u]) return; vis[u]=1; for (int i=0;i<G[u].size();i++) dfs1(G[u][i]); S.push_back(u); } void dfs2(int u) { if (sccno[u]) return; sccno[u]=scc_cnt; fo... 阅读全文

posted @ 2013-04-17 19:53 电子幼体 阅读(173) 评论(0) 推荐(0) 编辑

hdu 2767 Proving Equivalences 等价性证明 强连通分量

摘要: Proving EquivalencesTime Limit: 4000/2000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1641Accepted Submission(s): 619Problem DescriptionConsider the following exercise, found in a generic linear algebra textbook.Let A be an n × n matrix. Prove that the followin 阅读全文

posted @ 2013-04-17 15:07 电子幼体 阅读(175) 评论(0) 推荐(0) 编辑

SCC的Tarjan算法模板

摘要: #include <iostream> #include <vector> #include <stack> #include <cstring> #include <cstdio> using namespace std; const int maxn=41111; //-----Tarjan vector<int> G[maxn]; int pre[maxn],lowlink[maxn],sccno[maxn],dfs_clock,scc_cnt; stack<int> S; void dfs(int u) 阅读全文

posted @ 2013-04-17 14:58 电子幼体 阅读(600) 评论(0) 推荐(0) 编辑

导航