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

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
 
Recommend
Ignatius.L   |   We have carefully selected several similar problems for you:  1151 1281 1507 1528 1054 
 
最小点覆盖
 #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的更多相关文章

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

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

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

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

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

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

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

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

  5. hdu 1150 Machine Schedule 最少点覆盖

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

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

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

  7. HDU——1150 Machine Schedule

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

  8. 二分图最大匹配(匈牙利算法)简介& Example hdu 1150 Machine Schedule

    二分图匹配(匈牙利算法) 1.一个二分图中的最大匹配数等于这个图中的最小点覆盖数 König定理是一个二分图中很重要的定理,它的意思是,一个二分图中的最大匹配数等于这个图中的最小点覆盖数.如果你还不知 ...

  9. hdoj 1150 Machine Schedule【匈牙利算法+最小顶点覆盖】

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

随机推荐

  1. 让前端攻城师独立于后端进行开发: Mock.js

    一.Mock.js是什么? 目前的大部分公司的项目都是采用的前后端分离, 后端接口的开发和前端人员是同时进行的. 那么这个时候就会存在一个问题, 在页面需要使用大量数据进行渲染生成前, 后端开发人员的 ...

  2. 20130912.Windows下常用命令的使用(不断更新)

    Win+R================================ cmd => 命令行 lpksetup => 弹出安装或者卸载Windows显示语言 ipconfig => ...

  3. POI实现Excel2003插入多张图片

    POI的操作Excel时,不可避免有操作图片的处理.怎么插入图片呢?网上也有不少介绍. 下面的代码是向Excel中插入多张图片的例子: public static void main(String[] ...

  4. MySQL创建表时加入的约束以及外键约束的的意义

    1,创建表时加入的约束 a) 非空约束,not null b) 唯一约束,unique c) 主键约束,primary key d) 外键约束,foreign key 1,非空约束,针对某个字段设置其 ...

  5. Ubuntu 常用快捷键

    本系列文章由 @YhL_Leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/50285313 1 桌面 快捷键 作用 ...

  6. Java 获取环境变量

    Java 获取环境变量Java 获取环境变量的方式很简单: System.getEnv()  得到所有的环境变量System.getEnv(key) 得到某个环境变量的值 由于某些需要,可能要下载某些 ...

  7. xftp和xshell的使用

    Xftp和Xshell配合使用部署环境. (linux系统) Xftp为可视化工具.主要用来复制文件. xshell则通过输入命令来对server进行操作,如启动服务等等. 一.  Xftp的连接 新 ...

  8. 怎样用批处理来执行多个exe文件

    怎样用批处理来运行多个exe文件 @echo off start *****.exe start *****.exe start *****.exe start *****.exe 接着我们就能够运行 ...

  9. emitter 增强 多条件触发

    ;(function(global ,undefined){ var evts = {} ,onceTag = '__event_once' function emit(event ){ ) if ( ...

  10. m_Orchestrate learning system---十七、页面美观的关键是什么

    m_Orchestrate learning system---十七.页面美观的关键是什么 一.总结 一句话总结:图片用好看的 1.项目板块化? 就是一个个模块,能复用的话很快的 页面由这一个个模块拼 ...