hdu2063 过山车二分图匹配

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hdu2063 过山车二分图匹配相关的知识,希望对你有一定的参考价值。


题目链接:​​http://acm.hdu.edu.cn/showproblem.php?pid=2063​​​
题意:中文题
解析:二分图匹配裸题

#include <bits/stdc++.h>
using namespace std;
const int maxn = 5000;
struct node

int to,next;
edge[maxn];
int head[maxn],cnt;
int match[maxn],vis[maxn];
void init()

memset(head,-1,sizeof(head));
memset(match,0,sizeof(match));
cnt = 0;

void addEdge(int from,int to)

edge[cnt].to = to;
edge[cnt].next = head[from];
head[from] = cnt++;

bool dfs(int u)

for(int i=head[u];i!=-1;i = edge[i].next)

int v = edge[i].to;
if(vis[v]) continue;
vis[v] = 1;
if(!match[v] || dfs(match[v]))

match[v] = u;
match[u] = v;
return true;


return false;

int main(void)

int k;
while(~scanf("%d",&k)&&k)

int n,m;
init();
scanf("%d %d",&m,&n);
for(int i=0;i<k;i++)

int x,y;
scanf("%d %d",&x,&y);
addEdge(x,y+m);

int ans = 0;
for(int i=1;i<=m;i++)

memset(vis,0,sizeof(vis));
if(dfs(i))
ans++;

printf("%d\\n",ans);

return 0;


以上是关于hdu2063 过山车二分图匹配的主要内容,如果未能解决你的问题,请参考以下文章

hdu2063 过山车 二分图最大匹配

hdu 2063 过山车 二分图的最大匹配 匈牙利算法

过山车 HDU 2063 (二分图匹配裸题)

HDU2063(二分图最大匹配)

luogu3386 模板二分图匹配 匈牙利算法 hdu2063 过山车 dinic

hdu-2063-二分图最大匹配