POJ 2239 Selecting Courses
来源:互联网 发布:10天学会单片机 编辑:程序博客网 时间:2024/05/20 03:41
题目大意:在一个星期内上课,求最多能上多少种课程
思路:最大匹配,问的是课程数---->上课时间的匹配
program:
#include<iostream>
using namespace std;
#define M 301
#define N 85
bool map[M][N];
bool chk[N];
int match[N];
int n;
int dfs(int p)
{
int temp;//
for(int i=1;i<=84;i++)
{
if(!chk[i] && map[p][i] )
{
chk[i]=1;
temp=match[i];
match[i]=p;
if(temp==-1 || dfs(temp))return 1;//注意是或的关系
// 注意是dsf(temp)
match[i]=temp;
}
}
return 0;
}
int two_map()
{
int sum=0;
for(int i=1;i<=n;i++)//
{
memset(chk,0,sizeof(chk));
if(dfs(i))
sum++;
}
return sum;
}
int main()
{
int t,a,b;
while(scanf("%d",&n)!=EOF)
{
memset(map,0,sizeof(map));
memset(match,-1,sizeof(match));//
for(int i=1;i<=n;i++)
{
scanf("%d",&t);
for(int j=1;j<=t;j++)
{
scanf("%d%d",&a,&b);
map[i][(a-1)*12+b]=1;//表示开始有匹配 //构造节点来进行匹配
}
}
printf("%d\n",two_map());
}
return 0;}
- POJ 2239 Selecting Courses
- poj 2239 Selecting Courses
- POJ-2239 Selecting Courses
- poj 2239 Selecting Courses
- POJ 2239 Selecting Courses
- POJ-2239-Selecting Courses
- poj 2239 Selecting Courses
- POJ 2239-Selecting Courses
- poj 2239 Selecting Courses
- poj 2239 Selecting Courses
- poj 2239 Selecting Courses
- poj 2239 Selecting Courses
- poj 2239 Selecting Courses
- poj 2239 Selecting Courses 匹配
- POJ 2239:Selecting Courses 选课
- poj 2239 G - Selecting Courses
- POJ 2239 Selecting Courses (二分匹配)
- POJ 2239 Selecting Courses EK!匈牙利!SAP?
- SQL Server数据库表主键重置
- 1.3项目计划表
- 重建redo-oracle数据库恢复
- 一次遍历反转链表
- 黑马程序员_java学习笔记04
- POJ 2239 Selecting Courses
- Ubuntu下安装ROI_PAC小记
- [模板]三维几何模板
- connect android with adb over tcp
- mysql列类型char,varchar,text,tinytext,mediumtext,longtext的比较与选择
- Linux内存管理(5):分页机制和管理区初始化
- 一日总结之2012-08-26 Sun.
- 我的大二总结
- java中常见数据库字段类型与java.sql.Types的对应