poj--2239--Selecting Courses(最大匹配)
| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 9782 | Accepted: 4400 |
Description
as possible. Of course there should be no conflict among the courses he selects.
There are 12 classes every day, and 7 days every week. There are hundreds of courses in the college, and teaching a course needs one class each week. To give students more convenience, though teaching a course needs only one class, a course will be taught several
times in a week. For example, a course may be taught both at the 7-th class on Tuesday and 12-th class on Wednesday, you should assume that there is no difference between the two classes, and that students can select any class to go. At the different weeks,
a student can even go to different class as his wish. Because there are so many courses in the college, selecting courses is not an easy job for Li Ming. As his good friends, can you help him?
Input
7*12), the different time when students can go to study the course. Then come t pairs of integers p (1 <= p <= 7) and q (1 <= q <= 12), which mean that the course will be taught at the q-th class on the p-th day of a week.
Output
Sample Input
5
1 1 1
2 1 1 2 2
1 2 2
2 3 2 3 3
1 3 3
Sample Output
4
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int map[400][10][20];
int used[10][20],pipei[10][20];
int find(int x)
{
for(int i=1;i<=7;i++)
{
for(int j=1;j<=12;j++)
{
if(!used[i][j]&&map[x][i][j])
{
used[i][j]=1;
if(!pipei[i][j]||find(pipei[i][j]))
{
pipei[i][j]=x;
return 1;
}
}
}
}
return 0;
}
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
memset(map,0,sizeof(map));
memset(pipei,0,sizeof(pipei));
for(int i=1;i<=n;i++)
{
int t;
scanf("%d",&t);
while(t--)
{
int x,y;
scanf("%d%d",&x,&y);
map[i][x][y]=1;
}
}
int sum=0;
for(int i=1;i<=n;i++)
{
memset(used,0,sizeof(used));
sum+=find(i);
}
printf("%d\n",sum);
}
return 0;
}
poj--2239--Selecting Courses(最大匹配)的更多相关文章
- poj——2239 Selecting Courses
poj——2239 Selecting Courses Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10656 A ...
- poj 2239 Selecting Courses (二分匹配)
Selecting Courses Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8316 Accepted: 3687 ...
- [POJ] 2239 Selecting Courses(二分图最大匹配)
题目地址:http://poj.org/problem?id=2239 Li Ming大学选课,每天12节课,每周7天,每种同样的课可能有多节分布在不同天的不同节.问Li Ming最多可以选多少节课. ...
- poj 2239 Selecting Courses(二分匹配简单模板)
http://poj.org/problem?id=2239 这里要处理的是构图问题p (1 <= p <= 7), q (1 <= q <= 12)分别表示第i门课在一周的第 ...
- POJ 2239 Selecting Courses
二分图的最大匹配.课程和时间可以看做二分图. #include<cstdio> #include<cstring> #include<cmath> #include ...
- poj 2239 二分图最大匹配,基础题
1.poj 2239 Selecting Courses 二分图最大匹配问题 2.总结:看到一个题解,直接用三维数组做的,很巧妙,很暴力.. 题意:N种课,给出时间,每种课在星期几的第几节课上 ...
- POJ 2239:Selecting Courses 选课
Selecting Courses Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9380 Accepted: 4177 ...
- HDU 3697 Selecting courses(贪心)
题目链接:pid=3697" target="_blank">http://acm.hdu.edu.cn/showproblem.php?pid=3697 Prob ...
- hdu 3697 10 福州 现场 H - Selecting courses 贪心 难度:0
Description A new Semester is coming and students are troubling for selecting courses. Students ...
- HDU 3697 Selecting courses(贪心+暴力)(2010 Asia Fuzhou Regional Contest)
Description A new Semester is coming and students are troubling for selecting courses. Students ...
随机推荐
- Android Fragment间的广播消息接收
这种方式不用在配置文件加东西,我比较喜欢. 广播注册,可以写在Activity(onCreate),也可以写在Fragment(onActivityCreated)里. LocalBroadcastM ...
- 复习java第五天(枚举、Annotation(注释) 概述)
一.枚举 传统的方式: •在某些情况下,一个类的对象是有限而且固定的.例如季节类,只能有 4 个对象 •手动实现枚举类: —private 修饰构造器. —属性使用 private final 修饰. ...
- C++版的LLC代码
图像稀疏编码总结:LLC和SCSPM,文章对稀疏编码讲解非常详细. <Locality-constrained Linear Coding for Image Classification> ...
- git解决内容冲突
内容冲突的冲突处理 两个用户修改了同一个文件的同一块区域,git会报告内容冲突. 解决办法:打开发生冲突的文件,会发现 <<<<<<< HEADtest in ...
- Data mapping-数据映射
数据映射:根据数据的结构信息建立数据间的映射操作机制. 数据映射的要素: 一.数据 1.源数据: 2.目标数据: 3.数据间关系: 4.数据的元数据(结构信息). 5.元素类型的对应关系. 二.元数据 ...
- Memcached 之缓存雪崩现象、实际案例和缓存无底洞现象
一.缓存雪崩现象 由于集群中某个memcached服务器宕机的原因,造成集群中的服务器命中率下降.只能通过访问数据库得到数据,是的数据库的压力倍增,造成数据库服务器崩溃.重启数据库还是会崩溃,但是数据 ...
- 【转】在VMware中为Linux系统安装VM-Tools的详解教程
在VMware中为Linux系统安装VM-Tools的详解教程 如果大家打算在VMware虚拟机中安装Linux的话,那么在完成Linux的安装后,如果没有安装Vm-Tools的话,一部分功能将得不到 ...
- matlab学习滚动条改变文本数值
如下分别添加滚动条,静态文本框和可编辑文本框,字体大小改为10,string值按下图,并使用对齐工具 保存名为GUI_02,会自动出来一个.m文件 注意代码一个字都不要错 %定义变量var,保存滚动条 ...
- ffmpeg中关于EAGAIN的理解及非阻塞IO
ffmpeg为在linux下开发的开源音视频框架,所以经常会碰到很多错误(设置errno),其中EAGAIN是其中比较常见的一个错误(比如用在非阻塞操作中). try again,从字面上来看,是提 ...
- eas之如何获取当前用户
在UI扩展类中,获取当前用户可通过工具类SysContext如:SysContext.getSysContext().getCurrentUserInfo()在ControlerBean的扩展类中,获 ...