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 ...
随机推荐
- codevs 1519 过路费
时间限制: 1 s 空间限制: 256000 KB 题目等级 : 大师 Master 题目描述 Description 在某个遥远的国家里,有 n个城市.编号为 1,2,3,…,n.这个国家的政府 ...
- Charles Petzold 编程界大师,世界顶级技术作家 《CODE》值得阅读
<CODE>The Hidden Language of Computer Hardware and Software 从书内容的第一页开始就惊叹于作者的耐心和责任心 整本书以两个隔街对窗 ...
- 错误消息 This computer doesn't have VT-X/AMD-v enabled
在VirtualBox的Ubuntu虚拟机里试图本地安装Kyma(一个基于Kubernetes的开源框架)时,遇到下面的错误信息: E0827 11:19:38.972489 3093 start.g ...
- (转)SpringMVC学习(七)——Controller类的方法返回值
http://blog.csdn.net/yerenyuan_pku/article/details/72511844 本文所有案例代码的编写均建立在前文SpringMVC学习(六)——SpringM ...
- Linux之 if命令——简单的shell文件
如何写一个shell文件,写一个小脚本 1.新建一个脚本文件:vi demo.sh 2.追加执行权限: chmod u+x demo.sh 3.执行脚本:./demo.sh 4.什么是脚本?把一堆命令 ...
- Qt 之 QApplication
1.QApplication QApplication类管理GUI程序的控制流和主要设置,是基于QWidget的,为此特化了QGuiApplication的一些功能,处理QWidget特有的初始化和结 ...
- largest rectangle in histogram leetcode
Given n non-negative integers representing the histogram's bar height where the width of each bar is ...
- 2019西安多校联训 Day5
T1 光哥为了不让某初二奆佬恶心到我们而留下的火种 (貌似没这题平均分就100-了) 思路:就一横一竖让后就gztopa嘛 #include <bits/stdc++.h> using n ...
- Linux 命令学习(1): head和tail
版权声明:本文为博主原创文章,未经允许,不得转载. head head 命令可以将一段文本的开头一部分输出到标准输出. head命令既可以处理文本文件也可以处理标准输入. 基本应用 处理文本文件: h ...
- tornado框架基础10-websocket
websocket 01 长轮询 在网页,我们经常扫码登录,结合之前的学习的知识点,来思考下,前端是如何知道用户在手机上扫码登录了呢? 长轮询:客户端不断的向服务器发送请求 缺点: \1. 开销大 \ ...