Machine Schedule

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5817    Accepted Submission(s): 2932

Problem Description
As
we all know, machine scheduling is a very classical problem in computer
science and has been studied for a very long history. Scheduling
problems differ widely in the nature of the constraints that must be
satisfied and the type of schedule desired. Here we consider a 2-machine
scheduling problem.

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.

 
Input
The
input file for this program consists of several configurations. The
first line of one configuration contains three positive integers: n, m
(n, m < 100) and k (k < 1000). The following k lines give the
constrains of the k jobs, each line is a triple: i, x, y.

The input will be terminated by a line containing a single zero.

 
Output
The output should be one integer per line, which means the minimal times of restarting machine.
 
Sample Input
5 5 10
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
 
Sample Output
3
 
Source
 
代码:  最小点覆盖=最大匹配....
 #include<cstring>
#include<cstdio>
#include<cstdlib>
using namespace std;
int const maxn=;
int n,m,k;
bool mat[maxn][maxn];
bool vis[maxn];
int mac[maxn];
bool match(int x)
{
for(int i=;i<=m;i++)
{
if(mat[x][i]&&!vis[i]){
vis[i]=;
if(!mac[i]||match(mac[i])){
mac[i]=x;
return ;
}
}
}
return ;
}
int main(){
int a,b,c;
//freopen("test.in","r",stdin);
while(scanf("%d",&n),n!=){
memset(mat,,sizeof(mat));
memset(mac,,sizeof(mac));
scanf("%d%d",&m,&k);
for(int i=;i<k;i++){
scanf("%d%d%d",&a,&b,&c);
mat[b][c]=;
}
int ans=;
for(int i=;i<=n;i++){
memset(vis,,sizeof(vis));
if(match(i))ans++;
}
printf("%d\n",ans);
}
return ;
}

hdu-----(1150)Machine Schedule(最小覆盖点)的更多相关文章

  1. hdu 1150 Machine Schedule 最小覆盖点集

    题意:x,y两台机器各在一边,分别有模式x0 x1 x2 ... xn, y0 y1 y2 ... ym, 现在对给定K个任务,每个任务可以用xi模式或者yj模式完成,同时变换一次模式需要重新启动一次 ...

  2. HDU 1150 Machine Schedule (最小覆盖,匈牙利算法)

    题意: 有两台不同机器A和B,他们分别拥有各种运行模式1~n和1~m.现有一些job,需要在某模式下才能完成,job1在A和B上需要的工作模式又可能会不一样.两台机器一开始处于0模式,可以切换模式,但 ...

  3. 匈牙利算法模板 hdu 1150 Machine Schedule(二分匹配)

    二分图:https://blog.csdn.net/c20180630/article/details/70175814 https://blog.csdn.net/flynn_curry/artic ...

  4. hdu 1150 Machine Schedule(二分匹配,简单匈牙利算法)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1150 Machine Schedule Time Limit: 2000/1000 MS (Java/ ...

  5. hdu 1150 Machine Schedule(最小顶点覆盖)

    pid=1150">Machine Schedule Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/327 ...

  6. hdu 1150 Machine Schedule 最少点覆盖转化为最大匹配

    Machine Schedule Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...

  7. hdu 1150 Machine Schedule 最少点覆盖

    Machine Schedule Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...

  8. hdu 1150 Machine Schedule hdu 1151 Air Raid 匈牙利模版

    //两道大水……哦不 两道结论题 结论:二部图的最小覆盖数=二部图的最大匹配数 有向图的最小覆盖数=节点数-二部图的最大匹配数 //hdu 1150 #include<cstdio> #i ...

  9. hdu 1150 Machine Schedule (二分匹配)

    Machine Schedule Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  10. HDU——1150 Machine Schedule

    Machine Schedule Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

随机推荐

  1. [dataTables.js error] Uncaught TypeError: myTable.row is not a function

    使用dataTables.js时遇到的问题. 代码如下: var myTable = $('#dynamic-table') .dataTable({ bAutoWidth : false, &quo ...

  2. Entity Framework 不支持DefaultValue

    http://stackoverflow.com/questions/18506088/entityframework-not-updating-column-with-default-value Y ...

  3. (Theano 1)Theano自述文件

    Theano在GitHub上的自述文件 https://github.com/Theano/Theano 也不知道这个Theano好不好,但是从Theano到Lasagne:基于Python的深度学习 ...

  4. mysql获得自增字段下一个值

    初次研究: 表: sql: show table status from carsale_db LIKE 'tb_car' 结果: 想办法取得这其中的值.... 在Internet上找到这个资料: M ...

  5. CSS笔记(九)轮廓

    参考:http://www.w3school.com.cn/css/css_outline.asp CSS 边框属性 "CSS" 列中的数字指示哪个 CSS 版本定义了该属性. 属 ...

  6. 几个移动App测试工具

    介绍几款移动App测试的工具: 腾讯测试:http://bugly.qq.com/优测:http://utest.qq.com/fir.im测试:http://bughd.com/ 大致介绍如下: b ...

  7. git学习笔记05-从远程库克隆

    现在,假设我们从零开发,那么最好的方式是先创建远程库,然后,从远程库克隆. 首先,登陆GitHub,创建一个新的仓库,名字叫gitskills: 我们勾选Initialize this reposit ...

  8. JQery 中的 $(".bb:eq(1)") eq () 解释。。

    这是一段代码: <div id="bb">a</div> <div id="bb">b</div> <di ...

  9. iOS - Swift Range 范围

    前言 Range:结构体,这个结构体用来表示一个区间的范围. public struct Range<Element : ForwardIndexType> : Equatable, Co ...

  10. Redis基础知识之————如何处理客户端连接

    redis 连接建立 Redis Redis 通过监听一个 TCP 端口或者 Unix socket 的方式来接收来自客户端的连接,当一个连接建立后,Redis 内部会进行以下一些操作: 首先,客户端 ...