POJ 2239
#include<iostream>
#include<algorithm>
#define MAXN 305
using namespace std; int _m[MAXN][MAXN];
int time[][];
int match[MAXN];
bool ck[MAXN]; bool search(int a,int b,int x)
{
int i;
int t;
for ( i = ; i < b ; i++)
if (_m[x][i] && ! ck[i])
{
ck[i] = true;
t = match[i];
match[i] = x;
if (t == - || search(a,b,t))
return true;
match[i] = t;
}
return false;
} int hungary(int a,int b)
{
memset(match,-,sizeof(match));
int max_match = ;
int i;
for ( i = ; i < a ; i++)
{
memset(ck,false,sizeof(ck));
if (search(a,b,i))
max_match++;
}
return max_match;
} int main()
{
//freopen("acm.acm","r",stdin);
int n;
int num;
int i;
int j;
int u;
int v;
int k;
int node_num = ;
while(cin>>n)
{
node_num = ;
memset(_m,,sizeof(_m) );
memset(time,-,sizeof(time));
for(k = ; k < n; ++ k)
{
cin>>num;
for(i = ; i < num; ++ i)
{
cin>>u>>v;
-- u;
-- v;
if(time[u][v] == -)
{
time[u][v] = node_num ++;
_m[k][time[u][v]] = ;
}
else
{
_m[k][time[u][v]] = ;
}
}
}
cout<<hungary(n,node_num)<<endl;
} }
关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。

技术网站地址: vmfor.com
POJ 2239的更多相关文章
- poj 2239 二分图最大匹配,基础题
1.poj 2239 Selecting Courses 二分图最大匹配问题 2.总结:看到一个题解,直接用三维数组做的,很巧妙,很暴力.. 题意:N种课,给出时间,每种课在星期几的第几节课上 ...
- poj——2239 Selecting Courses
poj——2239 Selecting Courses Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10656 A ...
- poj 2239 Selecting Courses(二分匹配简单模板)
http://poj.org/problem?id=2239 这里要处理的是构图问题p (1 <= p <= 7), q (1 <= q <= 12)分别表示第i门课在一周的第 ...
- [POJ] 2239 Selecting Courses(二分图最大匹配)
题目地址:http://poj.org/problem?id=2239 Li Ming大学选课,每天12节课,每周7天,每种同样的课可能有多节分布在不同天的不同节.问Li Ming最多可以选多少节课. ...
- poj 2239 Selecting Courses (二分匹配)
Selecting Courses Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8316 Accepted: 3687 ...
- POJ 2239 Selecting Courses
二分图的最大匹配.课程和时间可以看做二分图. #include<cstdio> #include<cstring> #include<cmath> #include ...
- Selecting Courses POJ - 2239(我是沙雕吧 按时间点建边 || 匹配水题)
呃呃呃呃呃 把每个课给了INF个容量....我是沙雕把....emm....这题就是做着玩...呃呃呃别当真.... #include <iostream> #include <cs ...
- POJ 2239 匈牙利算法
思路:最大匹配 也是很裸的一道题-. // by SiriusRen #include <cstdio> #include <cstring> #include <alg ...
- POJ 2239:Selecting Courses 选课
Selecting Courses Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9380 Accepted: 4177 ...
随机推荐
- How to Restart Qt Application
How to restart QtApplication As we know, Restarting Application means to exit current application, t ...
- Golang 字符编码
需要添加的库 go get code.google.com/p/go.text/encoding go get code.google.com/p/go.text/transform 两个转码函数 i ...
- mybatis使用原始Dao开发中存在的问题
1.Dao方法存在重复代码:通过SqlSessionFactory创建SqlSession,调用SqlSession的送数据库操作方法. 2.调用SqlSession的数据库需要制定statement ...
- Castle ActiveRecord学习(七)使用日志
暂无 参考:http://terrylee.cnblogs.com/archive/2006/04/14/374829.html
- Java多线程同步方法
一.同步方法 即有synchronized关键字修饰的方法. 由于java的每个对象都有一个内置锁,当用此关键字修饰方法时, 内置锁会保护整个方法.在调用该方法前,需要获得内置锁,否则就处于阻塞状态. ...
- Go基本数据类型
Go基本数据类型 第一部分:基本数据类型和操作符 1. 文件名&关键字&标识符 1. 所有go源码以.go结尾 2. 标识符以字母或下划线开头,大小写敏感,比如: a. boy b. ...
- cpuinfo
在Linux系统中,如何详细了解CPU的信息呢? 当然是通过cat /proc/cpuinfo来检查了,但是比如几个物理CPU/几核/几线程,这些问题怎么确定呢? 经过查看,我的开发机器是1个物理CP ...
- docker 关于volumns的总结(转)
原文地址:http://www.cnblogs.com/ivictor/p/4834864.html Docker容器启动的时候,如果要挂载宿主机的一个目录,可以用-v参数指定. 譬如我要启动一个ce ...
- ZOJ3768 Continuous Login 2017-04-14 12:47 45人阅读 评论(0) 收藏
Continuous Login Time Limit: 2 Seconds Memory Limit: 131072 KB Special Judge Pierre is rec ...
- 23 DesignPatterns学习笔记:C++语言实现 --- 2.2 Adapter
23 DesignPatterns学习笔记:C++语言实现 --- 2.2 Adapter 2016-07-22 (www.cnblogs.com/icmzn) 模式理解