poj——2239   Selecting Courses
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 10656   Accepted: 4814

Description

It is well known that it is not easy to select courses in the college, for there is usually conflict among the time of the courses. Li Ming is a student who loves study every much, and at the beginning of each term, he always wants to select courses as more 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

The input contains several cases. For each case, the first line contains an integer n (1 <= n <= 300), the number of courses in Li Ming's college. The following n lines represent n different courses. In each line, the first number is an integer t (1 <= t <= 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

For each test case, output one integer, which is the maximum number of courses Li Ming can select.

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

POJ Monthly,Li Haoyuan

题目大意:

在大学里有许许多多的课程,现在小明需要去选择课程,他想尽可能多的选择课程。学校里有n(1 <= n <= 300)个课程,并且学校规定,每周里的每天有12节课,那么一周就有7*12节课。要求算出小明最多可以选择多少个课程。
输入有多组数据:
每组数据第一行为n,代表有n个课程。接下来n行,每行第一个数字x代表这个课程在这一周里面共有x次课。
然后跟着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的更多相关文章

  1. poj 2239 Selecting Courses (二分匹配)

    Selecting Courses Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8316   Accepted: 3687 ...

  2. poj 2239 Selecting Courses(二分匹配简单模板)

    http://poj.org/problem?id=2239 这里要处理的是构图问题p (1 <= p <= 7), q (1 <= q <= 12)分别表示第i门课在一周的第 ...

  3. [POJ] 2239 Selecting Courses(二分图最大匹配)

    题目地址:http://poj.org/problem?id=2239 Li Ming大学选课,每天12节课,每周7天,每种同样的课可能有多节分布在不同天的不同节.问Li Ming最多可以选多少节课. ...

  4. POJ 2239 Selecting Courses

    二分图的最大匹配.课程和时间可以看做二分图. #include<cstdio> #include<cstring> #include<cmath> #include ...

  5. poj 2239 二分图最大匹配,基础题

    1.poj 2239   Selecting Courses   二分图最大匹配问题 2.总结:看到一个题解,直接用三维数组做的,很巧妙,很暴力.. 题意:N种课,给出时间,每种课在星期几的第几节课上 ...

  6. POJ 2239:Selecting Courses 选课

    Selecting Courses Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9380   Accepted: 4177 ...

  7. HDU 3697 Selecting courses(贪心)

    题目链接:pid=3697" target="_blank">http://acm.hdu.edu.cn/showproblem.php?pid=3697 Prob ...

  8. hdu 3697 10 福州 现场 H - Selecting courses 贪心 难度:0

    Description     A new Semester is coming and students are troubling for selecting courses. Students ...

  9. HDU 3697 Selecting courses(贪心+暴力)(2010 Asia Fuzhou Regional Contest)

    Description     A new Semester is coming and students are troubling for selecting courses. Students ...

随机推荐

  1. 【转载】Hierarchal Temporal Memory (HTM)

    最近在看机器学习,看能否根据已有的历史来预测Hardware的故障发生概率.下文是一篇很有意思的文章,转自 http://numenta.org/htm.html. NuPIC是一个开源项目,用来实现 ...

  2. ArrayList Vector LinkedList分析

    1.创建 ArrayList 的底层是一个数组.  ArrayList<String> list1 = new ArrayList<>(); list1.add("a ...

  3. golang结构体排序 - 根据下载时间重命名本地文件

    喜M拉Y下载音频到手机,使用ximalaya.exe 解密[.x2m]为[.m4a]根据文件下载创建时间,顺序重命名文件,方便后续播放. 源码如下:package main import ( &quo ...

  4. 通过JS加载XML文件,跨浏览器兼容

    引言 通过JS加载XML文件,跨多种浏览器兼容. 在Chrome中,没有load方法,需要特殊处理! 解决方案 部分代码 try //Internet Explorer { xmlDoc=new Ac ...

  5. js中重载问题

    在js中是没有重载的  但是  Arguments对象(可以实现模拟重载的效果) 利用arguments对象的length属性,可以获取函数接收的参数的个数 例如: function add(){ i ...

  6. 课外作业(建立double类型的小数,按照四舍五入保留2位小数)

    举例:

  7. QT_1

    QT概述 1.1 QT 是一个跨平台的C++图形用户界面应用程序框架 1.2 发展史: 1991奇趣科技 1.3 QT 版本:商业版.开源版 1.4 优点: 1.4.1 跨平台 1.4.2 接口简单 ...

  8. webpack 之 plugin

    loader和plugins的区别是:前者处理单个文件,而后者作用于整个打包过程 内置插件:BannerPlugin 可以在打包后的文件上方添加备注信息,如版权说明等 // webpack.confi ...

  9. 如何用纯 CSS 创作一个充电 loader 特效

    效果预览 在线演示 按下右侧的"点击预览"按钮在当前页面预览,点击链接全屏预览. https://codepen.io/zhang-ou/pen/deNqdV 可交互视频教程 此视 ...

  10. Android API Guides 安卓API指导----第一部分:Introduction(介绍)

    第一部分: Introduction(介绍) 目录包含:APP  Fundamentals     (应用程序基础) Device   Compatibility(设备兼容性) System Perm ...