Ultraviolet A 11294 POJ 3648 Wedding
Question:
At the wedding, the bride and groom sit on both sides of the table. The bride can only see the opposite person. We know that some people have XX relationships... The bride does not want to see the relationship and sit on the opposite side and ask who the bride is when the conditions are met.
Ideas:
The constraint on the groom's side is most conducive to solving the problem, so it becomes a 2-sat question about whether a person wants to sit on the groom's side. Therefore, you can ask the groom's side first and then check the bride's side. Pay attention to the groom. it is required and cannot be associated with the groom...
Code:
#include
#include
#includeusing namespace std;#define N 70int 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]