HDU——T 1150 Machine Schedule
http://acm.hdu.edu.cn/showproblem.php?pid=1150
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 9463 Accepted Submission(s): 4757
There are two machines A and B. Machine A has n kinds of working modes, which is called mode_0, mode_1, …, mode_n-1, likewise machine B has m kinds of working modes, mode_0, mode_1, … , mode_m-1. At the beginning they are both work at mode_0.
For k jobs given, each of them can be processed in either one of the two machines in particular mode. For example, job 0 can either be processed in machine A at mode_3 or in machine B at mode_4, job 1 can either be processed in machine A at mode_2 or in machine B at mode_4, and so on. Thus, for job i, the constraint can be represent as a triple (i, x, y), which means it can be processed either in machine A at mode_x, or in machine B at mode_y.
Obviously, to accomplish all the jobs, we need to change the machine's working mode from time to time, but unfortunately, the machine's working mode can only be changed by restarting it manually. By changing the sequence of the jobs and assigning each job to a suitable machine, please write a program to minimize the times of restarting machines.
The input will be terminated by a line containing a single zero.
0 1 1
1 1 2
2 1 3
3 1 4
4 2 1
5 2 2
6 2 3
7 2 4
8 3 3
9 4 3
0
#include <cstring>
#include <cstdio> using namespace std; int n,m,t,match[];
bool map[][],vis[]; bool find(int u)
{
for(int v=;v<=m;v++)
if(map[u][v]&&!vis[v])
{
vis[v]=;
if(!match[v]||find(match[v]))
{
match[v]=u;
return true;
}
}
return false;
} int main()
{
for(int ans=;scanf("%d",&n)&&n;ans=)
{
scanf("%d%d",&m,&t);
for(int x,y,z;t--;map[y][z]=)
scanf("%d%d%d",&x,&y,&z);
for(int i=;i<=n;i++)
{
if(find(i)) ans++;
memset(vis,,sizeof(vis));
}
printf("%d\n",ans);
memset(map,,sizeof(map));
memset(match,,sizeof(match));
}
return ;
}
HDU——T 1150 Machine Schedule的更多相关文章
- 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(二分匹配)
二分图:https://blog.csdn.net/c20180630/article/details/70175814 https://blog.csdn.net/flynn_curry/artic ...
- hdu 1150 Machine Schedule(最小顶点覆盖)
pid=1150">Machine Schedule Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/327 ...
- 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? ...
- hdu 1150 Machine Schedule (二分匹配)
Machine Schedule Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- HDU——1150 Machine Schedule
Machine Schedule Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- 二分图最大匹配(匈牙利算法)简介& Example hdu 1150 Machine Schedule
二分图匹配(匈牙利算法) 1.一个二分图中的最大匹配数等于这个图中的最小点覆盖数 König定理是一个二分图中很重要的定理,它的意思是,一个二分图中的最大匹配数等于这个图中的最小点覆盖数.如果你还不知 ...
- hdoj 1150 Machine Schedule【匈牙利算法+最小顶点覆盖】
Machine Schedule Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
随机推荐
- 新手须知 QT类大全
QT类大全,在行内容中罗列出来了,希望大家多看看,如果是API就更好了,但可惜不是.这些是一些大类,请多做参考. QApplication 应用程序类 QLabel 标签类 QPushButton 按 ...
- tomcat闪退无法启动 the catalina_home environment variable is not defined correctly this environment variable is needed to run this program
未成功配置CATALINA_HOME 1.计算机>属性>环境变量, 新建环境变量.变量名为CATALINA_HOME ,变量值tomcat的解压目录,注意后面不用多加“\”或者“;” 2. ...
- spring security中当前用户信息
1:如果在jsp页面中获取可以使用spring security的标签库 在页面中引入标签 1 <%@ taglib prefix="sec" uri="htt ...
- Apache Mahout 0.9、10.1、11. CardinalityException: Required cardinality 60 but got 29
我们可以使用Apache Mahout来快速创建高效扩展性又好的机器学习应用.Mahout结合了诸如H2O算法.Scala.Spark和Hadoop MapReduce等模块,为开发人员提供了一个 ...
- linux svn命令具体解释
检測是否安装svn:svnserve --version svn服务的关闭:killall svnserve 创建svn库:svnadmin create /opt/svn/repos 配置自己主动启 ...
- LeetCode OJ 之 Number of Digit One (数字1的个数)
题目: Given an integer n, count the total number of digit 1 appearing in all non-negative integers les ...
- DataTables warning: table id=dataTable - Requested unknown parameter 'acceptId' for row 0. For more
重点内容 DataTables warning: table id=dataTable - Requested unknown parameter 'acceptId' for row 0. For ...
- netty底层是事件驱动的异步库 但是可以await或者sync(本质是future超时机制)同步返回 但是官方 Prefer addListener(GenericFutureListener) to await()
io.netty.channel 摘自:https://netty.io/4.0/api/io/netty/channel/ChannelFuture.html Interface ChannelFu ...
- nyoj--84--阶乘的0(数学技巧)
阶乘的0 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 计算n!的十进制表示最后有多少个0 输入 第一行输入一个整数N表示测试数据的组数(1<=N<=100 ...
- [jzoj 5926] [NOIP2018模拟10.25] naive 的图 解题报告(kruskal重构树+二维数点)
题目链接: https://jzoj.net/senior/#main/show/5926 题目: 题解: 显然最小的最大路径在最小生成树上(最小生成树=最小瓶颈生成树) 于是我们建出kruskal重 ...