1.邻接表(vector向量法)

vector<int> G[N];

int Search_Path(int s)
{
    for(int i=0;i<G[s].size();i++)
    {
        int v = G[s][i];
        if(!vis[v])
        {
            vis[v] = 1;
            if(match[v] == -1 || Search_Path(match[v]))
            {
                match[v] = s;
                return 1;
            }
        }
    }
    return 0;
}

//主函数中

for(i=0;i<=n;i++)
        G[i].clear();
memset(match,-1,sizeof(match));
cnt = 0;
    for(i=0;i<n;i++)
    {
        memset(vis,0,sizeof(vis));
        if(Search_Path(i))
            cnt++;
    }
View Code

相关文章:

  • 2021-05-26
  • 2021-10-31
  • 2022-12-23
  • 2022-01-04
  • 2022-12-23
  • 2021-09-16
  • 2022-12-23
猜你喜欢
  • 2021-11-27
  • 2021-07-06
  • 2022-12-23
  • 2022-12-23
  • 2021-05-20
  • 2021-11-20
相关资源
相似解决方案