poj——2239 Selecting Courses
| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 10656 | Accepted: 4814 |
Description
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
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
Source
题目大意:
输入有多组数据:
然后跟着x对数字,第一个p(1 <= p <= 7) 代表这周的哪一天,第二个q(1 <= q <= 12)代表这天的哪一节课.。
如果几个课程都在那d天的那c节课上课,那么你需要选择其中的一个,而不能选择多个课程
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define N 310
using namespace std;
bool vis[N];
int n,m,x,y,t,ans,pre[N],map[N][N];
int read()
{
,f=;char ch=getchar();
; ch=getchar();}
+ch-'; ch=getchar();}
return x*f;
}
int find(int x)
{
;i<=m;i++)
if(!vis[i]&&map[x][i])
{
vis[i]=true;
||find(pre[i]))
{
pre[i]=x;
;
}
}
;
}
int main()
{
while(~scanf("%d",&n))
{
ans=;m=*;
memset(map,,sizeof(map));
memset(pre,-,sizeof(pre));
;i<=n;i++)
{
t=read();
while(t--)
x=read(),y=read(),map[i][(x-)*+y]=;
}
;i<=n;i++)
{
memset(vis,,sizeof(vis));
if(find(i)) ans++;
}
printf("%d\n",ans);
}
;
}
poj——2239 Selecting Courses的更多相关文章
- 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 这里要处理的是构图问题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
二分图的最大匹配.课程和时间可以看做二分图. #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 ...
随机推荐
- Javaweb学习笔记7—JDBC技术
今天来讲javaweb的第7阶段学习. JDBC技术,关于JDBC本篇博客只介绍了它的一部分,后面博客会更加深入探讨. 老规矩,首先先用一张思维导图来展现今天的博客内容. ps:我的思维是用的 ...
- C# 图片打印杂谈
日常开头水一下,看了下上次博客,一年零八天了,啧啧,奢侈. 最近这个工作挺满意的,是我想要的发展方向,后续要做机器学习,现在得先把公司之前堆积的问题解决了. 谈人生到此结束,还是说正题吧.(感觉这标题 ...
- Oracle PL/SQL 编程手册(SQL大全)
一.SQLPLUS 1引言 SQL命令 以下17个是作为语句开头的关键字: alterdroprevoke auditgrantrollback* commit*inse ...
- Linux目录结构及详细介绍
/:根目录,位于Linux文件系统目录结构的顶层,一般根目录下只存放目录,不要存放文件,/etc./bin./dev./lib./sbin应该和根目录放置在一个分区中. /bin,/usr/bin:该 ...
- 在Vue中遇到的各种坑 及性能提升
Vue: (1) 没有再模板里引用data数据,会不会引起update.beforeUpdate生命周期函数的执行? 不会 (2)组件改成异步 (3)v-once (4)如果不用template ...
- Java Web 之 Jsp 常用语法总结
一.小脚本语法 <% code fragment %> 语法编写为XML的形式,效果相同,如下所示: <jsp:scriptlet> code fragment </js ...
- c++_凑算式(最新方法)
凑算式 B DEFA + --- + ------- = 10 C GHI (如果显示有问题,可以参见[图1.jpg]) 这个算式中A~I代表1~9的数字,不同的字母代表不同的数字. 比如:6+8/3 ...
- 在ubuntu16上搭建rabbitMQ环境
在ubuntu16上搭建rabbitMQ环境 安装rabbitMQ apt-cache pkgnames | grep rabbitmq apt-get install rabbitmq-server ...
- Canal使用报错解决办法
1. [destination = test_cancal , address = /127.0.0.1:3306 , EventParser] WARN c.a.o.s.a.i.setl.zooke ...
- 【HIHOCODER 1605】小Hi的生成树计数
描述 小Hi最近对生成树(包含所有顶点的联通无环子图.)非常的感兴趣,他想知道对于特定的简单平面无向图是不是存在求生成树个数的简单方法. 小Hi定义了这样的图:一个以{0,1,2--n}为顶点的图,顶 ...