hdu_3829 Cat VS Dog-Max Standalone set + build map

Source: Internet
Author: User

Test instructions: Zoo has n kinds of cats, m species of dogs, children like cats hate dogs, like dogs hate cats, as long as the children do not like things not, they are happy, ask their greatest happiness.

Analysis: The building is a difficult point, anyway I will not build, search the key to realize can build "contradiction side" this kind of thing. As long as the children like the things have conflict and even side, the last to find the largest independent set is the answer

/************************************************author:D arktongcreated time:2016/8/1 17:20:09File name:h du_3829.cpp*************************************************/#include<bits/stdc++.h>using namespacestd;Const intMAXN = -+Ten; Vector<int>W[MAXN];intN, M;intLEFT[MAXN];BOOLUSED[MAXN];BOOLMatchinti) {     for(intj=0; J<w[i].size (); ++j)if(!Used[w[i][j]]) {        intv =W[i][j]; USED[V]=true; if(! left[v]| |match (Left[v])) {Left[v]=i; return true; }    }    return false;}//returns the maximum number of matchesintHungary () {intres=0; Memset (left,0,sizeof(left));  for(intI=1; i<=n;++i) {memset (used,0,sizeof(used)); if(Match (i)) res++; }    returnRes;}Charpeo[maxn][2][5];intMain () {intT, cas=1; intp;  while(SCANF ("%d%d%d", &n, &m, &p) = =3)    {    //memset (w, 0, sizeof (w));         for(intI=0; i<maxn;++i) w[i].clear (); M=n=p;  for(intI=1; i<=n;++i) scanf ("%s%s", peo[i][0], peo[i][1]);  for(intI=1; i<=n;++i) for(intj=1; j<=n;++j)if(strcmp (peo[i][1], peo[j][0])==0) W[i].push_back (j), W[j].push_back (i); printf ("%d\n", (2*n-hungary ()) >>1); }        return 0;}

hdu_3829 Cat VS Dog-Max Standalone set + build map

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.