BZOJ1191 superhero hero (Hungarian algorithm)

Source: Internet
Author: User

Go directly to Hungary, notice that "only when the player correctly answer a question, you can enter the next question, or be eliminated", once unable to meet the direct exit.

1#include <cstdio>2#include <algorithm>3#include <cstring>4 #defineMAXN 20085 #defineMAXM 100086 7 structedge{8     intU,v,next;9 }EG[MAXM];Ten  One intn,m,sum; A intLAST[MAXN],L[MAXN]; - BOOLPD[MAXN]; -  the voidAddintUintv) - { -eg[++sum].u=u; -eg[sum].v=v; +eg[sum].next=Last[u]; -last[u]=sum; + } A BOOLFindintu) at { -      for(intI=last[u];i;i=eg[i].next) -     { -         intv=eg[i].v; -         if(!Pd[v]) -         { inpd[v]=true; -             if((!l[v]) | |find (L[v])) to             { +l[v]=u; -                 return true; the             } *              $         }Panax Notoginseng     } -     return false; the } + intMain () A { thescanf"%d%d",&n,&m); +     inti,j,sum=0, ans=0; -      for(i=1; i<=m;i++) $     { $scanf"%d",&j); - Add (i,j); -scanf"%d",&j); the Add (i,j); -     }Wuyi      thememset (L,0,sizeof(l)); -      for(i=1; i<=m;i++) Wu     { -memset (PD,0,sizeof(PD)); About         if(Find (i)) ans++;Else  Break;  $     } -printf"%d", ans); -}

BZOJ1191 superhero hero (Hungarian algorithm)

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.