Ultraviolet A 11294 POJ 3648 Wedding

Source: Internet
Author: User

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]
   
    

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.