匈牙利算法模板 hdu 1150 Machine Schedule(二分匹配)
二分图:https://blog.csdn.net/c20180630/article/details/70175814
https://blog.csdn.net/flynn_curry/article/details/52966283
匈牙利算法模板:https://blog.csdn.net/sunny_hun/article/details/80627351
例题:hdu 1150 Machine Schedule
参考:https://www.cnblogs.com/qq-star/p/4675600.html
https://www.cnblogs.com/kuangbin/archive/2012/08/19/2646928.html
注意:要用scanf输入输出!
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int N=;
int line[N][N],used[N],girl[N];
int n,m;//n相当于左点书,m右点数
bool find(int x)//模板
{
int j;
for (j=;j<m;j++)
{
if (line[x][j]==true && used[j]==false)
{
used[j]=;
if (girl[j]== || find(girl[j]))
{
girl[j]=x;
return true;
}
}
}
return false;
}
int main()
{
int k;
while (cin>>n)
{
if (!n)
{
break;
}
cin>>m>>k;
memset(line,,sizeof(line));
memset(girl,,sizeof(girl));
while (k--)
{
int ind,a,b;
cin>>ind>>a>>b;
line[a][b]=;
}
int ans=;
for (int i=;i<n;i++)//因为初始状态为0,所以不用考虑0状态
{
memset(used,,sizeof(used));
if (find(i))
{
ans++;
}
}
cout<<ans<<endl;
} return ;
}
匈牙利算法模板 hdu 1150 Machine Schedule(二分匹配)的更多相关文章
- hdu 1150 Machine Schedule (二分匹配)
Machine Schedule Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- hdu - 1150 Machine Schedule (二分图匹配最小点覆盖)
http://acm.hdu.edu.cn/showproblem.php?pid=1150 有两种机器,A机器有n种模式,B机器有m种模式,现在有k个任务需要执行,没切换一个任务机器就需要重启一次, ...
- hdu 1150 Machine Schedule(二分匹配,简单匈牙利算法)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1150 Machine Schedule Time Limit: 2000/1000 MS (Java/ ...
- hdu 1150 Machine Schedule(最小顶点覆盖)
pid=1150">Machine Schedule Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/327 ...
- 二分图最大匹配(匈牙利算法)简介& Example hdu 1150 Machine Schedule
二分图匹配(匈牙利算法) 1.一个二分图中的最大匹配数等于这个图中的最小点覆盖数 König定理是一个二分图中很重要的定理,它的意思是,一个二分图中的最大匹配数等于这个图中的最小点覆盖数.如果你还不知 ...
- HDU 1150 Machine Schedule (最小覆盖,匈牙利算法)
题意: 有两台不同机器A和B,他们分别拥有各种运行模式1~n和1~m.现有一些job,需要在某模式下才能完成,job1在A和B上需要的工作模式又可能会不一样.两台机器一开始处于0模式,可以切换模式,但 ...
- hdu 1150 Machine Schedule hdu 1151 Air Raid 匈牙利模版
//两道大水……哦不 两道结论题 结论:二部图的最小覆盖数=二部图的最大匹配数 有向图的最小覆盖数=节点数-二部图的最大匹配数 //hdu 1150 #include<cstdio> #i ...
- hdu 1150 Machine Schedule 最少点覆盖转化为最大匹配
Machine Schedule Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...
- hdu 1150 Machine Schedule 最少点覆盖
Machine Schedule Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...
随机推荐
- 在浏览器的市场上,IE依然是放弃了,firefox还在继续~~
自从微软失败后,发布了Edge:但是依然是没有多少市场的,毕竟各种难受: 单从开发者工具,我是没有其它选择了, ie的不能用,https://www.microsoft.com/en-us/welco ...
- 深入Python(1): 字典排序 关于sort()、reversed()、sorted()
http://www.cnblogs.com/BeginMan/p/3193081.html 一.Python的排序 1.reversed() 这个很好理解,reversed英文意思就是:adj. 颠 ...
- 初次撸Python,踩平些小坑~
[转义字符] os.path.isdir(targetPath)总是报错,以为字符串不行而是要转成file类型,尝试了很多方法还是没解决,最后发现,windows下的路径中字符串中需要转义(例子在网上 ...
- 查看锁定的session信息脚本
查看当前被阻塞的对象和锁信息SELECT DISTINCT s1.inst_id BlockingInst, s1.sid BlockingSid, s1.seri ...
- fiddler和charles
(4)学习浏览器代理和手机网络抓包,涉及到了fiddler和charles,
- Nodejs做整站转发
刚接触nodejs,做个东西练下手,通过nodejs直接转发整站,原本想把内容全翻译成英文,但google对流量行审查,被封IP,所以就没啥用了, 效果像这样 var b = function (a, ...
- Angularjs实例应用
<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...
- mui 的多图片上传
pickHead(){ var _this = this; plus.gallery.pick(function(path){ _this.headImage=path; var files = [{ ...
- 原 史上最简单的SpringCloud教程 | 第八篇: 消息总线(Spring Cloud Bus)(Finchley版本)
转载请标明出处: 原文首发于:https://www.fangzhipeng.com/springcloud/2018/08/30/sc-f8-bus/ 本文出自方志朋的博客 转载请标明出处: Spr ...
- About Unity3D 4.1.2 (to continue…)
Here are something that need to take care of when you work with Unity3D: 1) It seems Unity3D could c ...