The bare maximum match.
1#include <cstdio>2#include <vector>3#include <cstring>4 using namespacestd;5vector<int>g[2002];6typedef vector<int>:: iterator ITER;7 intn,m,mat[2002],x,y;8 BOOLvis[2002];9 BOOLDfsintU)Ten { One for(ITER it=g[u].begin (); It!=g[u].end (); it++) A if(!vis[*it]) - { -vis[*it]=1; the if(mat[*it]==-1|| DFS (mat[*it])) - { -mat[*it]=U; - return 1; + } - } + return 0; A } at intMax_match () - { -memset (mat,-1,sizeof(MAT));intres=0; - for(intI=1; i<=n;i++) - { -memset (Vis,0,sizeof(Vis)); in if(Dfs (i)) res++; - Else returnRes; to}returnRes; + } - intMain () the { *scanf"%d%d",&m,&n); $ for(intI=1; i<=n;i++)Panax Notoginseng { -scanf"%d%d",&x,&y); theG[i].push_back (x+1+n); +g[x+1+N].push_back (i); AG[i].push_back (y+1+n); theg[y+1+N].push_back (i); +} printf ("%d\n", Max_match ()); - return 0; $}
"Binary map" "Maximum Match" "Hungarian algorithm" bzoj1191 [HNOI2006] superhero hero