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 ...
随机推荐
- WEB前端JS与UI框架
前端Js框架汇总 概述: 有些日子没有正襟危坐写博客了,互联网飞速发展的时代,技术更新迭代的速度也在加快.看着Java.Js.Swift在各领域心花路放,也是煞是羡慕.寻了寻.net的消息,也是振奋人 ...
- SQLite -语法
SQLite -语法 SQLite是紧随其后的是独特的组称为语法的规则和指导方针.本教程为您提供了快速启动和SQLite的清单的所有基本SQLite语法. 大小写敏感性 注意重要的一点是,SQLite ...
- (转)编码剖析@Resource注解的实现原理
http://blog.csdn.net/yerenyuan_pku/article/details/52860046 上文我们已经学会使用@Resource注解注入属性.学是学会了,但也仅限于会使用 ...
- vue :class 可以接收 字符串 数组 和 对象 对象里面的key值 根据true或false 显示不显示
vue :class 可以接收 字符串 数组 和 对象 对象里面的key值 根据true或false 显示不显示 https://cn.vuejs.org/v2/guide/class-and-sty ...
- 树状数组 || POJ 3321 Apple Tree
一道dfs序+树状数组的题 因为并没有get到dfs序以及对树状数组也不熟练卡了很久orz dfs序: in和out是时间戳 dfs序可以将树转化成为一个序列,满足区间 -> 子树 然后就可以用 ...
- 筛选法 || POJ 3292 Semi-prime H-numbers
5,9,13,……叫H-prime 一个数能且仅能由两个H-prime相乘得到,则为H-semi-prime 问1-n中的H-semi-prime有多少个 *解法:vis初始化为0代表H-prime, ...
- react随笔-1(为什么在react使用jq无法正确渲染组件位置)
今天心血来潮,打开了sublime想玩玩react,然后大家都知道的先引入一大串 就是在百度静态资源库里找到的. 然后贴html代码 对的,没错,就这么一行,毕竟只是测试嘛 然后js代码 大家一定要注 ...
- set容器几个关键函数
set在OI中非常好用,归纳几种常见的功能qwq #include<iostream> #include<cstdio> #include<set> //set容器 ...
- MySQL连接使用及分类
SQL连接 SQL 连接(JOIN)子句用于将数据库中两个或者两个以上表中的记录组合起来.连接通过共有值将不同表中的字段组合在一起. 考虑下面两个表,(a)CUSTOMERS 表:+----+---- ...
- Linux基础学习-RHEL7.4之YUM更换CentOS源
1.配置YUM本地源 1.挂载镜像 [root@qdlinux ~]# mount /dev/cdrom /mnt 2.查看是否挂载成功 [root@qdlinux ~]# df -h Filesys ...