poj 1274 The Perfect Stall
来源:互联网 发布:阿里云隐藏域名信息 编辑:程序博客网 时间:2024/06/10 03:47
题目:http://poj.org/problem?id=1274
//题目大意:不同的牛偏爱在某些牛棚产奶,希望找到牛和牛棚所相互匹配的最大配对数 #include<stdio.h>#include<memory.h>int a[201][201];int used[201];int pair[201];int m,n;//m为牛的数目,n为牛棚的数目bool find(int x){for(int i=1;i<=n;i++){if(a[x][i]==1 && used[i]==0){used[i]=1;if(pair[i]==0 || find(pair[i])==true){pair[i]=x;return true;}}}return false;} int main(){while(~scanf("%d %d",&m,&n)){memset(a,0,sizeof(a));memset(pair,0,sizeof(pair));int ei;for(int i=1;i<=m;i++){int n;scanf("%d",&n);for(int j=1;j<=n;j++){scanf("%d",&ei);a[i][ei]=1;}}int ans=0;for(int i=1;i<=m;i++){memset(used,0,sizeof(used));if(find(i)){ans++;}}printf("%d\n",ans);}return 0;}
阅读全文
0 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 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
- Html 特殊符号 让版权符号更美观
- CC3200系列教程之IIC主机——注意点
- 探索两个变量
- 闲来无聊,搭建一个Shadowsocks玩玩
- 调用高德导航,百度导航,腾讯地图
- poj 1274 The Perfect Stall
- ffmpeg音频处理——pcm格式与resample(重采样)
- 提升ListView的运行效率
- C++用new和不用new创建类对象区别
- H5新标签
- java集合
- iOS开发 实时监听UITextField内容的变化
- OPENCV3.0 单目摄像头标定(使用官方自带的标定图片)
- I2C总线与EEPROM