#include<iostream>
#include<algorithm>
#define MAXN 305
using namespace std; int _m[MAXN][MAXN];
int time[][];
int match[MAXN];
bool ck[MAXN]; bool search(int a,int b,int x)
{
int i;
int t;
for ( i = ; i < b ; i++)
if (_m[x][i] && ! ck[i])
{
ck[i] = true;
t = match[i];
match[i] = x;
if (t == - || search(a,b,t))
return true;
match[i] = t;
}
return false;
} int hungary(int a,int b)
{
memset(match,-,sizeof(match));
int max_match = ;
int i;
for ( i = ; i < a ; i++)
{
memset(ck,false,sizeof(ck));
if (search(a,b,i))
max_match++;
}
return max_match;
} int main()
{
//freopen("acm.acm","r",stdin);
int n;
int num;
int i;
int j;
int u;
int v;
int k;
int node_num = ;
while(cin>>n)
{
node_num = ;
memset(_m,,sizeof(_m) );
memset(time,-,sizeof(time));
for(k = ; k < n; ++ k)
{
cin>>num;
for(i = ; i < num; ++ i)
{
cin>>u>>v;
-- u;
-- v;
if(time[u][v] == -)
{
time[u][v] = node_num ++;
_m[k][time[u][v]] = ;
}
else
{
_m[k][time[u][v]] = ;
}
}
}
cout<<hungary(n,node_num)<<endl;
} }

关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。

技术网站地址: vmfor.com

POJ 2239的更多相关文章

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

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

  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 这里要处理的是构图问题p (1 <= p <= 7), q (1 <= q <= 12)分别表示第i门课在一周的第 ...

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

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

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

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

  6. POJ 2239 Selecting Courses

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

  7. Selecting Courses POJ - 2239(我是沙雕吧 按时间点建边 || 匹配水题)

    呃呃呃呃呃 把每个课给了INF个容量....我是沙雕把....emm....这题就是做着玩...呃呃呃别当真.... #include <iostream> #include <cs ...

  8. POJ 2239 匈牙利算法

    思路:最大匹配 也是很裸的一道题-. // by SiriusRen #include <cstdio> #include <cstring> #include <alg ...

  9. POJ 2239:Selecting Courses 选课

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

随机推荐

  1. javascript+php实现根据用户时区显示当地时间的方法

    本文实例讲述了javascript+php实现根据用户时区显示当地时间的方法.分享给大家供大家参考.具体如下: 在跨时区应用中会用到下面代码,这是以前写的一段代码. 服务器保存相关时间配置,保存形式为 ...

  2. golang之流程控制(注意点)

    Go在流程控制方面特点如下: 没有do和while循环,只有一个广义的for语句 switch语句灵活多变,还可以用于类型判断 if语句和switch语句都可以包含一条初始化子语句 break语句和c ...

  3. CF 990 Educational Codeforces Round 45

    既然补了就简单记录一下. 感觉还算有一点营养. 官方题解传送门:点我 A Commentary Boxes 对拆掉$n \mod m$个和新建$m - (n \mod m)$求个最小. #includ ...

  4. Socket发送文件

    .Net.cs using System; using System.Collections.Generic; using System.IO; using System.Linq; using Sy ...

  5. 阅读xtrabackup代码的一点笔记

    xtrabackup binary最重要的两个过程是backup和prepare,对应的函数分别是xtrabackup_backup_func()和xtrabackup_prepare_func(), ...

  6. handsontable-cell features

    数据验证:在columns中设置validator,进行同步或异步验证,还可添加beforeValidate, afterValidate函数,allowInvalid:true可以不用验证 var ...

  7. [label][OS] 制作 U 盘安装 Windows 7

    U盘安装完美的WIN7操作系统教程 [编辑] 请使用正版系统   http://item.jd.com/965031.html   以保证您的电脑信息安全 此教程适用与 win7及win8 准备工作 ...

  8. 使用memset初始化C++自定义类型

    当类型本身或者类型的成员变量带有虚函数以及像std::vector这类复杂数据结构的时候.就会出错,原因是memset把类型本身所带的一些隐含的信息也给置0了.如:虚表指针.std::vector的内 ...

  9. pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

    # 背景 安装pip后发现执行pip install pytest,提示下面错误 pip is configured with locations that require TLS/SSL, howe ...

  10. jmeter测试mysql数据库之JDBC请求

    所有jmeter基本组件功能本文不做介绍.jmeter要链接mysql数据库,首先得下载mysql jdbc驱动包(注:驱动包的版本一定要与你数据库的版本匹配,驱动版本低于mysql版本有可能会导致连 ...