http://acm.hdu.edu.cn/showproblem.php?pid=1068
Because there is no gender specified, so to split, I split I and I ' So u=v-m (M is the maximum match, U maximum independent set, V is the number of vertices)
2u=2v-2m so u=n-m '/2. (Not much to see) but it doesn't. WA.
1#include <iostream>2#include <cstdio>3#include <cmath>4#include <vector>5#include <cstring>6#include <string>7#include <algorithm>8#include <string>9#include <Set>Ten#include <functional> One#include <numeric> A#include <sstream> -#include <stack> -#include <map> the#include <queue> - #pragmaComment (linker, "/stack:102400000,102400000") - #defineCL (arr, Val) memset (arr, Val, sizeof (arr)) - + #definell Long Long - #defineINF 0x7f7f7f7f + #defineLC L,m,rt<<1 A #defineRC M + 1,r,rt<<1|1 at #definePi ACOs (-1.0) - - #defineL (x) (x) << 1 - #defineR (x) (x) << 1 | 1 - #defineMID (L, R) (L + R) >> 1 - #defineMin (x, y) (x) < (y)? (x): (y) in #defineMax (x, y) (x) < (y)? (y): (x) - #defineE (x) (1 << (x)) to #defineIabs (x) (x) < 0? -(x): (x) + #defineOut (x) printf ("%i64d\n", X) - #defineLowbit (x) (x) & (-X) the #defineRead () freopen ("A.txt", "R", stdin) * #defineWrite () freopen ("B.txt", "w", stdout); $ #defineMAXN 1000000000Panax Notoginseng #defineN 510 - #defineMoD 1000000000 the using namespacestd; + Avector<int>G[n]; the intLink[n]; + BOOLVis[n]; - $ BOOLDfsintu) $ { - for(intI=0; I<g[u].size (); i++) - { the intv=G[u][i]; - if(!Vis[v])Wuyi { thevis[v]=true; - if(link[v]==-1||DFS (Link[v])) Wu { -link[v]=u; About return true; $ } - } - } - return false; A } + intMain () the { - //Read (); $ intn,a,b,c; the while(~SCANF ("%d",&N)) the { the for(intI=0; i<n;i++) g[i].clear (); the for(intI=0; i<n;i++) - { inscanf"%d: (%d)",&a,&b); the //printf ("%d%d\n", A, b); the for(intI=0; i<b;i++) About { thescanf"%d",&c); the G[a].push_back (c); the } + } - intcn1=0; thememset (link,-1,sizeof(link));Bayi for(intI=0; i<n;i++) the { thememset (Vis,0,sizeof(Vis)); - if(Dfs (i)) ans++; - } theprintf"%d\n", n-ans/2); the } the return 0; the}
hdu-1068 Girls and Boys (binary graph Max Independent set + split)