Title Address: http://acm.hdu.edu.cn/showproblem.php?pid=2063
Girls for x set, boys for y set, to find the maximum number of binary graphs can be.
1#include <cstdio>2#include <iostream>3#include <string.h>4#include <algorithm>5#include <math.h>6#include <stdbool.h>7#include <time.h>8#include <stdlib.h>9#include <Set>Ten#include <map> One#include <stack> A#include <queue> -#include <vector> - using namespacestd; the #defineCLR (x, y) memset (x,y,sizeof (×)) - #defineSQR (x) ((x) * (x)) - #defineRep (i,a,b) for (int i= (a); i<= (b); i++) - #defineLL Long Long + #defineINF 0x3f3f3f3f - #defineA First + #defineB Second A #definePI ACOs (-1.0) at Const intn= -+131; - intN,m,k,f[n],g[n][n],link[n]; - - voidInit () - { -CLR (F,0); inCLR (g,0); -CLR (link,-1); to } + - BOOLFindintx) the { * for(intI=1; i<=n;i++) { $ if(!f[i] &&G[x][i]) {Panax Notoginsengf[i]=1; - if(link[i]==-1||find (Link[i])) { thelink[i]=x; + return true; A } the } + } - $ return false; $ } - - intHungary () the { - intans=0;Wuyi for(intI=1; i<=m;i++) { theCLR (F,0); - if(Find (i)) ans++; Wu } - returnans; About } $ - intMain () - { - intu,v,k; A + while(~SCANF ("%d",&k)) { the if(!k) Break; - init (); $scanf"%d%d",&m,&n); the while(k--) { thescanf"%d%d",&u,&v); theg[u][v]=1; the } -printf"%d\n", Hungary ()); in } the the About the return 0; the}
[HDU] 2063 roller coaster (two-figure maximum match)