摘要:艰难的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
阅读全文
摘要: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
阅读全文
摘要: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[
阅读全文
摘要: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){
阅读全文
摘要: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)
阅读全文
摘要: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)
阅读全文