hdu 2063(二分图模板测试)

int mp[maxn][maxn];
int book[maxn],vis[maxn],sum;
bool dfs(int x)
{
    for(int i=1;i<=m;i++)
    {
        if(mp[x][i]&&!vis[i]){
            vis[i]=1;
            if(book[i]==0||dfs(book[i])){
                book[i]=x;
                return 1;
            }
        }
    }
    return 0;
}
int solve()
{
    int sum=0;
    memset(book,0,sizeof(book));
    for(int i=1; i<=n; i++){
        memset(vis,0,sizeof(vis));
        if(dfs(i)) sum++;
    }
    return sum;
}

 

posted @ 2017-11-09 23:17  啦啦啦天啦噜  阅读(179)  评论(0编辑  收藏  举报