poj 3041 Asteroids (二分匹配)
2012-08-02 15:31
465 查看
点击打开链接
简单二分匹配,直接模版。。#include"stdio.h"
#include"string.h"
int map[501][501],v[501],mark[501],link[501];
int n,k;
int dfs(int k)
{
int i;
for(i=1;i<=n;i++)
{
if(map[k][i]==1&&!v[i])
{
v[i]=1;
if(link[i]==0||dfs(link[i]))
{
link[i]=k;
return 1;
}
}
}
return 0;
}
int main()
{
int i,count,a,b;
while(scanf("%d%d",&n,&k)!=-1)
{
count=0;
memset(map,0,sizeof(map));
for(i=0;i<k;i++)
{
scanf("%d%d",&a,&b);
map[a][b]=1;
}
for(i=1;i<=n;i++)
{
memset(v,0,sizeof(v));
if(dfs(i))
count++;
}
printf("%d\n",count);
}
return 0;
}
相关文章推荐
- POJ 3041 Asteroids(二分匹配-hungary)
- POJ 3041 Asteroids(二分匹配)
- POJ-3041 Asteroids,二分匹配解决棋盘问题。
- POJ 3041 Asteroids(二分匹配)
- POJ 3041 Asteroids 二分匹配 最小点覆盖
- poj 3041 Asteroids (二分匹配)
- POJ 3041 Asteroids(模板——二分最大匹配(BFS增广))
- poj 3041 Asteroids 最小顶点覆盖 && 二分匹配
- poj 3041 Asteroids (二分匹配)
- poj 3041 Asteroids(二分匹配,最小点覆盖)
- 【POJ】-3041-Asteroids(二分最大匹配)
- 【POJ】3041 Asteroids 二分匹配
- poj 3041 Asteroids 二分匹配 匈牙利算法 模板题
- POJ 3041 Asteroids(二分匹配模板题)
- POJ 3041 Asteroids 二分匹配
- POJ 3041-Asteroids(二分匹配_最小点覆盖)
- POJ 3041 Asteroids(最大二分匹配)
- POJ 3041 Asteroids (二分匹配)
- poj-3041-Asteroids【二分匹配&&最小顶点覆盖】
- POJ 3041 Asteroids (二分匹配)