poj 1274 二分图 最大匹配
来源:互联网 发布:ubuntu 登录samba 编辑:程序博客网 时间:2024/05/18 20:06
传送门
题意:奶牛与挤奶器吧,一只奶牛只想用指定的某几个挤奶器,问最多能有几只在挤奶。(差不多就这意思吧)
思路:构造二分图,然后匈牙利算法求最大匹配数。
#include<iostream>#include<cstdio>#include<cstring>using namespace std;int m,n,num,ans,u,l[205];bool p[205][205],v[205];bool go(int x){ for(int i=1;i<=m;i++) { if(p[x][i]==1&&!v[i]) { v[i]=1; if(l[i]==-1||go(l[i])) { l[i]=x; return true; } } } return false;}int main(){ while(scanf("%d%d",&n,&m)!=EOF) { ans=0; memset(p,0,sizeof(p)); for(int i=1;i<=n;i++) { scanf("%d",&num); for(int j=0;j<num;j++) { scanf("%d",&u); p[i][u]=1; } } memset(l,-1,sizeof(l)); for(int i=1;i<=n;i++) { memset(v,0,sizeof(v)); if(go(i))ans++; } cout<<ans<<endl; } return 0;}
- POJ 1274 二分图最大匹配
- poj 1274 二分图 最大匹配
- poj 1274 二分图最大匹配
- poj 1274(二分图最大匹配)
- POJ 1274 / POJ 1469 / POJ 2239 二分图最大匹配
- poj 2446 poj 1469 poj 1274 二分图最大匹配
- 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 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 The Perfect Stall 1274 (二分图最大匹配)
- Windows2008下IIS7.0缓冲区太小的解决办法
- SQL 小记
- 3D Features, Surface Normals, Local Descriptors and KdTree
- 创业公司如何应对大公司抄袭
- 框架技术--Spring自动加载配置
- poj 1274 二分图 最大匹配
- asp导航条子菜单横向
- mysql 将时间戳直接转换成普通日期格式
- 我的CSDN帐号
- out/target/common/obj/PACKAGING/public_api.txt android.view.KeyEvent.KEYCODE_has changed value from
- SQL Server-- 存储过程中错误处理
- 【※硬件基础之内存的物理结构和工作原理※】系统收藏
- 字符串反转
- java 基本数据类型