//初始时需要将w初始化为0
int Left[MAXN];//Left[i]为左边与右边第i个点匹配的编号 int w[MAXN][MAXN]; bool S[MAXN],T[MAXN]; int N; bool match(int i) { S[i]=true; for(int j=1;j<=N;j++)if(w[i][j]&&!T[j]) { T[j]=true; if(Left[j]==0||match(Left[j])) { Left[j]=i; return true; } } return false; }
//返回的是最大匹配数
int hungry(){
CL(Left,0); int sum=0; for(int i=1;i<=N;i++) { CL(S,0); CL(T,0); if(match(i))sum++; } return sum; }