2011年3月19日

poj 3683

摘要: 艰难的ac。代码:#include<iostream>#include<fstream>#include<vector>using namespace std;vector<int> edge[2001],edge2[2001];int n,m;int v[2001],low[2001],dfn[2001],stack[2001],scc[2001],tot,index,top;void tarjan(int s){ int i,j,k; dfn[s]=low[s]=++index; stack[++top]=s; v[s]=1; for(i=0 阅读全文

posted @ 2011-03-19 20:48 宇宙吾心 阅读(594) 评论(0) 推荐(0)

poj 3648

摘要: 2sat,注意题意。代码:#include<iostream>#include<fstream>using namespace std;struct e{ int data; e *next;}edge[121],edge2[122];int n,m;int v[121],low[121],dfn[121],stack[121],scc[121],tot,index,top;void tarjan(int s){ int i,j,k; dfn[s]=low[s]=++index; stack[++top]=s; v[s]=1; e *p=edge[s].next; wh 阅读全文

posted @ 2011-03-19 18:03 宇宙吾心 阅读(508) 评论(0) 推荐(0)

poj 2749

摘要: 2sat。邻接表会超时。代码:#include<iostream>#include<fstream>#include<cmath>#include<vector>using namespace std;vector<int> edge[1001],edge2[1001];int n;int v[1001],low[1001],dfn[1001],stack[1001],scc[1001],tot,index,top;void tarjan(int s){ int i,j,k; dfn[s]=low[s]=++index; stack[ 阅读全文

posted @ 2011-03-19 16:23 宇宙吾心 阅读(395) 评论(0) 推荐(0)

poj 2723

摘要: 2sat直接过。代码:#include<iostream>#include<fstream>using namespace std;struct e{ int data; e *next;}edge[2300];int n,m;int v[2300],low[2300],dfn[2300],stack[2300],scc[2300],tot,index,top;void tarjan(int s){ int i,j,k; dfn[s]=low[s]=++index; stack[++top]=s; v[s]=1; e *p=edge[s].next; while(p){ 阅读全文

posted @ 2011-03-19 13:47 宇宙吾心 阅读(371) 评论(0) 推荐(0)

poj 3678

摘要: a AND b =1等价于(a || b) && (!a || b)&& (!b || a) =1a AND b =0等价于 !a || !b =1a OR b =0 等价于 !a AND !b=1等价于(!a || !b) && (!a || b)&& (!b || a) =1a OR b =1等价于 a || b =1a XOR b =1等价于(a || b) && (!a || !b) =1a XOR b =0 等价于 a XOR !b =1等价于(a || !b) && (!a || b) 阅读全文

posted @ 2011-03-19 12:53 宇宙吾心 阅读(482) 评论(0) 推荐(0)

poj 1330

摘要: 模板题。LCA(u){Make-Set(u)ancestor[Find-Set(u)]=u对于u的每一个孩子v{LCA(v)Union(u)ancestor[Find-Set(u)]=u}checked[u]=true对于每个(u,v)属于P{ifchecked[v]=truethen{回答u和v的最近公共祖先为ancestor[Find-Set(v)]}}} 代码:#include<iostream>#include<fstream>using namespace std;struct e{ int data; e *next;}edge[10001];int f[1 阅读全文

posted @ 2011-03-19 11:22 宇宙吾心 阅读(304) 评论(0) 推荐(0)

poj 3207

摘要: 2sat建好图就没问题。代码:#include<iostream>#include<fstream>using namespace std;struct e{ int data; e *next;}edge[1001];int n,m;int a[501],b[501];int cmp(const void *a,const void *b){ return *(int *)a-*(int *)b;}int v[1001],low[1001],dfn[1001],stack[1001],scc[1001],tot,index,top;void tarjan(int s) 阅读全文

posted @ 2011-03-19 10:27 宇宙吾心 阅读(408) 评论(0) 推荐(0)

poj 2311

摘要: 注意如何转化为nim。代码:#include<iostream>#include<fstream>using namespace std;int g[201][201];int v[201][201];int n,m;int solve(int s,int t){ int i,j,k; if(v[s][t]) return g[s][t]; bool v2[400]={0}; v[s][t]=1; for(i=2;i<=s/2;i++) { j=solve(i,t); k=solve(s-i,t); v2[j^k]=1; } for(i=2;i<=t/2;i 阅读全文

posted @ 2011-03-19 09:35 宇宙吾心 阅读(459) 评论(0) 推荐(0)

导航