poj 匈牙利二分匹配算法2239 Selecting Courses
来源:互联网 发布:微软雅黑字体 mac 编辑:程序博客网 时间:2024/04/27 01:21
和1274 差不多,我在1274 写的详细,这道题 用一下三维数组,和模板一个道理
#include<iostream>
using namespace std;
int map[310][15][15],pa[15][15],vis[15][15];
int find(int x)
{
for(int i=1;i<=7;i++)
{
for(int j=1;j<=12;j++)
{
if(map[x][i][j]&&!vis[i][j])
{
vis[i][j]=1;
if(pa[i][j]==-1||find(pa[i][j]))
{
pa[i][j]=x;
return 1;
}
}
}
}
return 0;
}
int main()
{
int n,p,x,y;
while(cin>>n)
{
for(int i=0;i<310;i++)
{
for(int j=0;j<15;j++)
{
for(int m=0;m<15;m++)
{
map[i][j][m]=0;
pa[m][j]=-1;
}
}
}
for(int i=1;i<=n;i++)
{
scanf("%d",&p);
while(p--)
{
scanf("%d%d",&x,&y);
map[i][x][y]=1;
}
}
int cou=0;
for(int i=1;i<=n;i++)
{
memset(vis,0,sizeof(vis));
if(find(i))
cou++;
}
cout<<cou<<endl;
}
return 0;
}
- poj 匈牙利二分匹配算法2239 Selecting Courses
- POJ 2239 Selecting Courses(二分匹配匈牙利啊)
- POJ 2239 Selecting Courses(二分图匹配——匈牙利算法||网络流)解题报告
- POJ 2239 Selecting Courses (二分匹配)
- 【POJ】2239 Selecting Courses 二分匹配
- POJ 2239 - Selecting Courses(二分图匹配)
- Poj 2239 Selecting Courses 【二分匹配】
- poj2239 Selecting Courses(最大二分图匹配 (匈牙利算法) 实现 )
- POJ2239 Selecting Courses(二分图匹配,匈牙利算法)
- poj 2239 Selecting Courses 匹配
- poj 2239 Selecting Courses 二分图最大匹配数
- poj 2239 Selecting Courses 二分图最大匹配
- POj 2239 Selecting Courses(二分图匹配)
- Poj 2239 Selecting Courses 二分图最大匹配
- POJ 2239 Selecting Courses(二分图最大匹配)
- POJ 2239 Selecting Courses(二分图最大匹配)
- POJ 2239 Selecting Courses(二分图匹配)
- poj 2239 Selecting Courses 二分图最大匹配
- Redis源代码分析之三:散列表——Dict(下)
- servlet
- 藕斷絲連
- 著名漏洞扫描工具IBM Rational AppScan 7.8.0.2 - 简体中文版下载(含破解补...
- [转].Net中的AutoScrollPosition问题 (panel 滚动条的位置设定)
- poj 匈牙利二分匹配算法2239 Selecting Courses
- 经典类库
- 关于android 调用网页隐藏地址栏
- IBM 3630 M3 虚拟化笔录(vmware Esxi5.0及由此想到的流水帐)
- 在word文档中自动加上行号
- PHP中autoload的使用方法
- printf大部分参数详解
- 软文写作的几个技巧,灰常给力
- apache做反向代理服务器