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)