http://poj.org/problem?id=1274&&The Perfect Stall
来源:互联网 发布:高通骁龙835超频软件 编辑:程序博客网 时间:2024/05/17 02:59
此题是二分图最大匹配模板题,,,,杯具的是匈牙利算法我竟然写错两个地方,,这一题简单题意不解释。。。
#include<iostream>#include<string.h>#define N 201#include<vector>using namespace std;bool visit[N];int match[N] ;int n,m;vector<int>map[N];bool dfs(int x){ for(int i=0;i<map[x].size();++i) if(!visit[map[x][i]]) { visit[map[x][i]]=true; if(match[map[x][i]]==-1||dfs(match[map[x][i]])) { match[map[x][i]]=x; return true; } } return false;}int main(){ while(cin>>n>>m) { memset(match,-1,sizeof(match)); for(int i=0;i<=n;++i) map[i].clear(); for(int i=1;i<=n;++i) { int s; cin>>s; for(int j=0;j<s;++j) { int a; cin>>a; map[i].push_back(a); } } int ans=0; for(int i=1;i<=n;++i) { memset(visit,false,sizeof(visit)); if(dfs(i)) ans++; } cout<<ans<<endl; }return 0; }
- http://poj.org/problem?id=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 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
- 眼睛直观感受几种常用排序算法
- 6个重要的.NET概念: - 堆栈,堆,值类型,引用类型,装箱和拆箱
- 酷壳陈皓:如何学好C语言
- 酷壳陈皓:如何学好C++语言
- 修改apache默认字符编码--在页面中显示乱码
- http://poj.org/problem?id=1274&&The Perfect Stall
- 无法嵌入互操作类型“stdole.StdFontClass”的解决方法
- JS只能输入正整数
- .NET中栈和堆的比较
- VisionMobile:移动平台生态系统冲突报告(十三)Chapter C:Windows Phone
- 火狐浏览器上类似HTTPWATCH的插件
- 【数据处理】ABAP程序代码效率优化
- 五大算法之二--动态规划
- 使用AT命令和GPRS无线模块开发(软件)