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. vue同胞组件通讯解决方案(以下为一种另外可用vuex解决)

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  2. ML-学习提纲1

    http://www.sohu.com/a/130379077_468714 本文用一系列「思维导图」由浅入深的总结了「统计学」领域的基础知识,是对之前系列文章做的一次完整的梳理,也是我至今为止所有与 ...

  3. 关于Ubuntu上的服务文件

    问题发现 今天在给ubuntu系统安装ftp服务时,一件奇怪的事引起了我的注意.当我服务安装完成后,想要测试一下是否能控制服务,便输入如下命令: service vsftpd restart 它返回的 ...

  4. QT 学习笔记概述

    以下笔记为在看书和实践的过程中的部分记录总结: 0. 窗口布局 1) 支持绝对布局和布局管理器布局; 2) 绝对布局不够灵活.无法自动调整大小,需要手动编写代码调整: 3) 布局管理器管理布局比较灵活 ...

  5. windows常用bat脚本

    windows常用bat脚本 https://blog.csdn.net/longyan_csc/article/details/78737722 Windows_批处理+任务计划实现文件夹定时备份 ...

  6. uva1352 Colored Cubes LA3401

    白书第一章例题8 好麻烦! 正方体每面编号为0-5,那么根据顶点和正面,就能确定形态.一共6*4=24种形态. P[i]表示编号i所在位置.比如P[1]=3,表示第二面转到了第四面. 就可以表示出所有 ...

  7. .NET多线程总结

    1.不需要传递参数,也不需要返回参数 我们知道启动一个线程最直观的办法是使用Thread类,具体步骤如下: public void test() { ThreadStart threadStart = ...

  8. activitmq+keepalived+nfs 非zk的高可用集群构建

    nfs 192.168.10.32 maast 192.168.10.4 savel 192.168.10.31 应对这个需求既要高可用又要消息延迟,只能使用变态方式实现 nfs部署 #yum ins ...

  9. 深入理解typeof操作符

    typeof可以检测数据的类型 typeof返回结果的其实是字符串:可以通过以下测试出来 console.log( typeof(typeof(a))); // string typeof返回的数据类 ...

  10. 计算机网络之传输层 下(TCP)

    1. TCP的特点 特点:它是一个点到点的通信机制,只能有一个发送方和一个接收方:它提供是一个可靠的,按序的字节流机制:使用流水线机制,通过拥塞控制和流量控制的机制设置窗口尺寸:发送方和接收方都有缓存 ...