题意:
婚礼上新郎新娘坐在桌子两侧 新娘只能看见对面的人 已知一些人有XX关系… 新娘不想看见有关系的同时坐在对面 问 满足条件的情况下 新娘这边做的人是谁
思路:
新郎那一边的约束最多 有利于解题 那么就变成了 一个人要不要坐新郎这边的2-sat问题 因此可以先求新郎这边的人 然后反一下就是新娘这边的了 注意 新郎是必选点 而且 不能选和新郎有XX关系的…
代码:
#include
#include
#include
using namespace std; #define N 70 int n,m,tot,top,idx,cnt; int dfn[N],low[N],st[N],instack[N],belong[N],col[N],in[N],head[N],opt[N],qu[N]; struct edge { int u,v,next; }ed[N*N*2]; void add(int u,int v) { ed[tot].u=u; ed[tot].v=v; ed[tot].next=head[u]; head[u]=tot++; } void tarjan(int u) { int i,v; dfn[u]=low[u]=++idx; instack[u]=1; st[++top]=u; for(i=head[u];~i;i=ed[i].next) { v=ed[i].v; if(dfn[v]==-1) { tarjan(v); low[u]=min(low[u],low[v]); } else if(instack[v]&&dfn[v]