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); } ; }
最新文章
- 使用命令行+ideal 工具实现本地代码项目提交
- (转) java定时器的几种用法
- python 2.43 升级到2.7
- iOS开发 Masonry的简单使用
- H5 Canvas刮刮乐
- HandlerMethodArgumentResolver数据绑定无效
- 运用加密技术保护Java源代码/定制ClassLoader
- vim替换及多行注释命令
- C++实现日期类(Date类)
- android studio安装后卡在fetching Android sdk compoment information
- 高性能网络I/O框架-netmap源码分析
- bzoj1042
- App设计相关网站
- git中使用命令将远程仓库拉取项目在本地文件夹
- webToImage (网页转图片)模块试用分享
- Io流的使用
- 用Hadoop AVRO进行大量小文件的处理(转)
- YYKit @autoreleasepool 使用,优化内存
- scrapy中Request中常用参数
- Stay true to yourself