#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. GPS坐标转换为百度地图坐标

    /** * GPS坐标转换为百度地图坐标 * 需要引入javabase64.jar 和json的一些包 * */ public class Gps2BaiDu { public static void ...

  2. [原创]解决IPCH关闭后可能引发的无法调试的BUG

    前几天清理硬盘,发现大量IPCH目录,文件特别巨大,看着头大,所以决定改为临时模式,同时VS2015和VS2013我都改了,设置如下: (关键字:IPCH目录,VS大文件) 当设置好之后不会出现烦人的 ...

  3. 斜杠反斜杠,去空格\xa0,连接函数join()

    1斜杠反斜杠 斜杠:/.反斜杠:\. 反斜杠\,在windows系统中用来表示目录. 而在unix系统中,/表示目录.由于web遵循unix命名,所以在网址(URL)中,/表示目录. 在unix系统中 ...

  4. 一起做RGB-D SLAM(8) (关于调试与补充内容)

    “一起做”系列完结后,我收到不少同学给我的反馈.他们提了一些在程序编译/运行过程中的问题.我把它们汇总起来,组成了这个“补充篇”.你也可以看成是一个Q&A. Q: OpenCV的版本?A: 我 ...

  5. app开发中如何利用sessionId来实现服务端与客户端保持回话

    app开发中如何利用sessionId来实现服务端与客户端保持回话 这个问题太过于常见,也过于简单,以至于大部分开发者根本没有关注过这个问题,我根据和我沟通的开发者中,总结出来常用的方法有以下几种: ...

  6. POJ1679 The Unique MST 2017-04-15 23:34 29人阅读 评论(0) 收藏

    The Unique MST Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 29902   Accepted: 10697 ...

  7. [label][JavaScript][The Defined Guide of JavaScript] 变量的作用域

    变量的作用域 一个变量的作用域(scope)是程序中定义这个变量的区域. 全局(global)变量的作用域(scope)是全局性的,即在JavaScript代码中,它处处都有定义.    而在函数之内 ...

  8. [react001] 使用webpack自动构建react 项目

    1.react 简介 React 是一个Facebook出品的前端UI开发框架.react官方的tutorials 为了让人容易上手,并没有给在平常工作使用react的详细配置,随意学习的深入,你为了 ...

  9. 关于Office软件中Word输入时卡顿无反应的解决办法!

    最近在安装office2013时遇到了这样一个问题,就是在激活office之后,打开Word输入内容时十分卡顿.也是狂搜网上各种办法,有说改注册表的,也有说在office选项里设置什么输入法的,全试了 ...

  10. Visual Studio 2013的新特性介绍

    cnbeta新闻:微软正式发布Visual Studio 2013 RTM版,微软还发布了Visual Studio 2013的最终版本..NET 4.5.1以及Team Foundation Ser ...