[算法] poj 1274 The Perfect Stall (匈牙利)
来源:互联网 发布:2017人工智能大会 编辑:程序博客网 时间:2024/05/21 17:20
#include <iostream>#include <cstdio>#include <cstring>using namespace std;const int N = 205;bool map[N][N];int mat[N];bool vis[N];int n, m;bool dfs(int u) { for(int i = 1; i <= m; i++) { if(map[u][i] && !vis[i]) { vis[i] = true; if(mat[i] == 0 || dfs(mat[i])) { mat[i] = u; return true; } } } return false;}int maxMatch() { memset(mat, 0, sizeof(mat)); int count = 0; for(int i = 1; i <= n; i++) { memset(vis, 0, sizeof(vis)); if(dfs(i)) count++; } return count;}int main() { while(scanf("%d%d", &n, &m) == 2) { memset(map, 0, sizeof(map)); int ca, j; for(int i = 1; i <= n; ++i) { scanf("%d", &ca); while(ca--) { scanf("%d", &j); map[i][j] = 1; } } printf("%d\n", maxMatch()); } return 0;}
- POJ 1274 The Perfect Stall ( 匈牙利算法 )
- [算法] poj 1274 The Perfect Stall (匈牙利)
- Poj-1274-The Perfect Stall-匈牙利算法
- poj 1274 The Perfect Stall(匈牙利算法)
- POJ 1274 The Perfect Stall (匈牙利算法)
- poj 1274 The Perfect Stall(匈牙利算法模板)
- POJ 1274 The Perfect Stall (匈牙利算法模板)
- POJ 1274 The Perfect Stall(匈牙利算法模板)
- POJ 1274 -- The Perfect Stall (匈牙利)
- poj 匈牙利二分匹配 1274 The Perfect Stall
- poj--1274--The Perfect Stall(匈牙利裸题)
- POJ 1274The Perfect Stall (二分图最大匹配问题,匈牙利算法实现)
- poj 1274The Perfect Stall(二分最大匹配法——匈牙利算法)
- POJ 1274 The Perfect Stall (二分图最大匹配入门题,匈牙利算法)
- POJ 1274The Perfect Stall(二分图匹配/匈牙利算法)
- poj1274 The Perfect Stall (匈牙利算法)
- poj 1274 The Perfect Stall
- poj 1274 The Perfect Stall
- Uva - 11825 - Hackers' Crackdown(状态压缩dp)
- SQL查询超时的设置方法
- 打印出所有的“水仙花数”,所谓“水仙花数”是指一个三位数,其各位数字立方和等于该数本身。例如:153是一个“水仙花数”,因为153=1的三次方+5的三次方+3的三次方
- hdu 4544 湫湫系列故事——消灭兔子(优先队列+贪心)
- OpenMP: 程序for循环并行效率优化
- [算法] poj 1274 The Perfect Stall (匈牙利)
- 你的搜索其实很糟糕?
- Hadoop1.0.4集群安装
- Android基于box2d开发弹弓类游戏[0]
- 符号链接与硬链接的区别
- 查看seesion 信息
- java中的反射一(Class类的认识)
- NSIS 如果让插件调用回调
- ubuntu12.04 取消主目录下文件在桌面上面的图形显示