http://poj.org/problem?id=2239

这里要处理的是构图问题p (1 <= p <= 7), q (1 <= q <= 12)分别表示第i门课在一周的第p天的第q节课上

其中二分图的X集合里表示课程i,那么我们要解决的就是Y集合了

将第i门课在一周的第p天的第q节课上进行编号,这样Y集合就是

上课时间的编号了

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<queue>
#include<algorithm>
#define INF 0x3f3f3f3f
#define N 310 using namespace std; int G[N][N], maps[N][N], vis[N], used[N];
int n, x; bool Find(int u)
{
int i;
for(i = ; i <= x ; i++)
{
if(!vis[i] && G[u][i])
{
vis[i] = ;
if(!used[i] || Find(used[i]))
{
used[i] = u;
return true;
}
}
}
return false;
} int main()
{
int p, q, n, i, j, m;
x = ;
memset(maps, , sizeof(maps));
for(i = ; i <= ; i++)
{
for(j = ; j <= ; j++)
{
maps[i][j] = x++;
}
}//构图
while(~scanf("%d", &n))
{
memset(G, , sizeof(G)); for(i = ; i <= n ; i++)
{
scanf("%d", &m);
while(m--)
{
scanf("%d%d", &p, &q);
G[i][maps[p][q]] = ;
}
}
memset(used, , sizeof(used));
int ans = ;
for(i = ; i <= n ; i++)
{
memset(vis, , sizeof(vis));
if(Find(i))
ans++;
}
printf("%d\n", ans);
}
return ;
}

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

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

  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 1469(裸二分匹配)

    COURSES Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 18993   Accepted: 7486 Descript ...

  6. POJ-1274The Perfect Stall,二分匹配裸模板题

    The Perfect Stall Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 23313   Accepted: 103 ...

  7. poj 3057(bfs+二分匹配)

    题目链接:http://poj.org/problem?id=3057 题目大概意思是有一块区域组成的房间,房间的边缘有门和墙壁,'X'代表墙壁,'D'代表门,房间内部的' . '代表空区域,每个空区 ...

  8. poj 1469 COURSES (二分匹配)

    COURSES Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 16877   Accepted: 6627 Descript ...

  9. poj 2594 Treasure Exploration (二分匹配)

    Treasure Exploration Time Limit: 6000MS   Memory Limit: 65536K Total Submissions: 6558   Accepted: 2 ...

随机推荐

  1. HTML5游戏开发_是男人就下100层

    项目流程 市场调研(可行性分析)--> 可行性报告书  需求分析师.客户经理 需求分析--> 需求说明书  项目经理.需求分析师 概要设计--> 概要设计说明书(ER图, UML)  ...

  2. 使用JAVA直观感受快速排序与冒泡排序的性能差异

    初学算法,肯定会编写排序算法 其中两个最为有名的就是冒泡排序和快速排序 理论上冒泡排序的时间复杂度为O(N^2),快速排序的时间复杂度为O(NlogN) 下面本门使用JAVA,分别编写三段排序程序 对 ...

  3. 移动金融APP分析

    最近研究了移动互联网金融APP的情况,分享给大家. 这是官方关于互联网金融的范围,包括支付.借贷.众筹.基金.保险和信托. 典型的APP 绑卡的流程普遍采用的四要素鉴权:姓名,身份证,卡号以及银行预留 ...

  4. Maven的功用所引发的哲学思想

    我们知道Maven有三个仓库 本地仓库 ~/.m2/repository/ 每一个用户也可以拥有一个本地仓库 远程仓库 中央仓库:Maven默认的远程仓库 http://repo1.maven.org ...

  5. 【英语】Bingo口语笔记(32) - 口语中的弱读

  6. T-SQL备忘(3):分组合并

    --CREATE TABLE test(code varchar(50), [name] varchar(10),[count] int ) --INSERT test SELECT '001' , ...

  7. Python time mktime()方法

    描述 Python time mktime() 函数执行与gmtime(), localtime()相反的操作,它接收struct_time对象作为参数,返回用秒数来表示时间的浮点数. 如果输入的值不 ...

  8. MongoDB数据库和集合的状态信息

    查看数据库统计信息:db.stats()  > use testswitched to db test> db.stats(){        "db" : " ...

  9. android 横竖屏限制如何配置

    在开发android的应用中,有时候需要限制横竖屏切换.只需要在AndroidManifest.xml文件中加入android:screenOrientation属性限制. ndroid:screen ...

  10. Microsoft Visual Studio Web 创作组件安装失败的解决方法

    在网上查一下说是Office2007的问题.我把Office2007卸载了还是不行. 然后用Windows Install Clean Up工具清理,还是不行. 郁闷了.然后在安装包中的下面路径下找到 ...