Codevs 2494 Vani and Cl2 hide and seek

Source: Internet
Author: User

/*at first, thought and Bzoj on the sacrifice is the same (after all, the same example) here do not know the adjacent points can reach each other indirectly connected can also be reached, so floyed first set up a relationship and then run the largest independent set of 95 and 100 below the code (carefully read the title to protect Peace)*/#include<iostream>#include<cstdio>#include<cstring>#defineMAXN 210#defineMAXM 30010using namespacestd;intN,M,HEAD[MAXN],NUM,ANS,MATCH[MAXN];BOOLF[MAXN];structnode{intU,v,pre;} E[MAXM];voidADD (int  from,intTo ) {num++; E[NUM].U= from; E[NUM].V=to ; E[num].pre=head[ from]; head[ from]=num;}intDfs (ints) {     for(intI=head[s];i;i=e[i].pre) {          intv=e[i].v; if(f[v]==0) {F[v]=1; if(match[v]==0||Dfs (Match[v])) {Match[v]=s; return 1; }          }      }    return 0;}intMain () {scanf ("%d%d", &n,&m);intx, y;  for(intI=1; i<=m;i++) {scanf ("%d%d",&x,&y);      ADD (x, y); }     for(intI=1; i<=n;i++) {memset (F,0,sizeof(f)); Ans+=Dfs (i); }    intp=n-ans; printf ("%d\n", p); return 0;}
#include <iostream>#include<cstdio>#include<cstring>#defineMAXN 210using namespacestd;intN,M,G[MAXN][MAXN],ANS,MATCH[MAXN];BOOLF[MAXN];intDfs (ints) {     for(intI=1; i<=n;i++)      if(f[i]==0&&g[s][i]==1) {F[i]=1; if(match[i]==0||Dfs (Match[i])) {Match[i]=s; return 1; }        }    return 0;}intMain () {scanf ("%d%d",&n,&m); intx,y;ans=N;  for(intI=1; i<=m;i++) {scanf ("%d%d",&x,&y); G[x][y]=1; }     for(intk=1; k<=n;k++)       for(intI=1; i<=n;i++)         for(intj=1; j<=n;j++) G[i][j]=g[i][j]| | (g[i][k]&&G[k][j]);  for(intI=1; i<=n;i++) {memset (F,0,sizeof(f)); Ans-=Dfs (i); } printf ("%d\n", ans); return 0;}

Codevs 2494 Vani and Cl2 hide and seek

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.