Machine Schedule

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

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
 
题意:
有两台机器,各有n和m个工作模式,k个任务,i x y,第i个任务可以由第一台机器的x模式执行或者第2台机器的y模式执行,每个机器如果换了一个模式就要重新启动,问最少的重启次数,最开始都在0模式
从零模式开始不用启动即第一次不用启动。
代码:
 // 最小点覆盖模板  一个模式可以同时执行多个任务。这就是最小点覆盖掉所有的边。
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int mp[][],vis[],link[];
int n,Mu,Mv,m,k;
int dfs(int x)
{
for(int i=;i<Mv;i++)
{
if(!vis[i]&&mp[x][i])
{
vis[i]=;
if(link[i]==-||dfs(link[i]))
{
link[i]=x;
return ;
}
}
}
return ;
}
int Maxcon()
{
int ans=;
memset(link,-,sizeof(link));
for(int i=;i<Mu;i++)
{
memset(vis,,sizeof(vis));
if(dfs(i)) ans++;
}
return ans;
}
int main()
{
int a,b,c;
while(scanf("%d",&n)&&n)
{
scanf("%d%d",&m,&k);
memset(mp,,sizeof(mp));
while(k--){
scanf("%d%d%d",&c,&a,&b);
if(a!=&&b!=) mp[a][b]=; //0模式不用
}
Mu=n;Mv=m; //左右集合
printf("%d\n",Maxcon());
}
return ;
}

*HDU1150 二分图的更多相关文章

  1. HDU1150 Machine Schedule(二分图最大匹配、最小点覆盖)

    As we all know, machine scheduling is a very classical problem in computer science and has been stud ...

  2. hdu-1150(二分图+匈牙利算法)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1150 思路:题目中给出两个机器A,B:给出k个任务,每个任务可以由A的x状态或者B的y状态来完成. 完 ...

  3. 【hdu1150】【Machine Schedule】二分图最小点覆盖+简单感性证明

    (上不了p站我要死了,侵权度娘背锅) 题目大意 有两台机器A和B以及N个需要运行的任务.每台机器有M种不同的模式,而每个任务都恰好在一台机器上运行.如果它在机器A上运行,则机器A需要设置为模式ai,如 ...

  4. 「日常温习」Hungary算法解决二分图相关问题

    前言 二分图的重点在于建模.以下的题目大家可以清晰的看出来这一点.代码相似度很高,但是思路基本上是各不相同. 题目 HDU 1179 Ollivanders: Makers of Fine Wands ...

  5. HDU-1150-MachineSchedule(二分图匹配)

    链接:https://vjudge.net/problem/HDU-1150#author=0 题意: 在一个工厂,有两台机器A,B生产产品.A机器有n种工作模式(模式0,模式1....模式n-1). ...

  6. C - NP-Hard Problem(二分图判定-染色法)

    C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144 ...

  7. POJ 2125 Destroying the Graph 二分图最小点权覆盖

    Destroying The Graph Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 8198   Accepted: 2 ...

  8. bzoj4025 二分图

    支持加边和删边的二分图判定,分治并查集水之(表示我的LCT还很不熟--仅仅停留在极其简单的模板水平). 由于是带权并查集,并且不能路径压缩,所以对权值(到父亲距离的奇偶性)的维护要注意一下. 有一个小 ...

  9. hdu 1281 二分图最大匹配

    对N个可以放棋子的点(X1,Y1),(x2,Y2)......(Xn,Yn);我们把它竖着排看看~(当然X1可以对多个点~) X1   Y1 X2   Y2 X3   Y3 ..... Xn   Yn ...

随机推荐

  1. Linux 执行文件查找命令 which 详解

    某个文件不知道放在哪里了,通常可以使用下面的一些命令来查找: which  查看可执行文件的位置 whereis 查看文件的位置 locate   配合数据库查看文件位置 find   实际搜寻硬盘查 ...

  2. 【Alpha】Daily Scrum Meeting第十次

    一.本次Daily Scrum Meeting主要内容 每个人学习情况 测试的任务的安排 Alpha版本展示的具体内容 二.任务安排 学号尾数 昨天做的任务 今天做的任务 任务用时 612 完成将计时 ...

  3. php万年历

    最近学习php循环.日期显示.GET方式请求,进而实现了一个小程序. 直接上代码: <?php header("Content-type:text/html; charset=UTF- ...

  4. iOS开发——高级篇——二维码的生产和读取

    一.二维码的生成 从iOS7开始集成了二维码的生成和读取功能此前被广泛使用的zbarsdk目前不支持64位处理器 生成二维码的步骤:导入CoreImage框架通过滤镜CIFilter生成二维码 二维码 ...

  5. sdcms标签

    模板防盗:<%if not in_sdcms then response.write("template load fail"):response.end() end if% ...

  6. 时下手机和p2p理财的共同点

    1, 雨后春笋,百家争鸣:一会听说这个又做手机了,一会听说哪哪哪又搞了个P2P. 2, 性价比高的都得靠抢:手机配置高价格低的要抢:p2p利率高时间短的要抢. 3, 竞争惨烈:手机千元机各种血拼:P2 ...

  7. OpenCV 2.4.13 编译使用(VS2015下)

    OpenCV2.4.13编译(VS2015) 这里给出已经编译好的的下载路径.包括Win64的debug和release版本. OpenCV for MSVC14 Win64 1.下载OpenCV源码 ...

  8. 关于用bootstrap显示查询的后台数据

    PrintWriter pw = response.getWriter(); pw.println(sb); pw.flush(); 由于用bootstrap查询数据,页面需要自身返回bootstra ...

  9. java 跨域

    jsonp做前端跨域需要服务器的支持的,造成json字符串前缀 var a=...或者 a[].... 实在有点麻烦,故还是后台跨域取数据好了 package com.pro.domain; impo ...

  10. node.js grunt文件压缩

    对于前段来说,熟悉node的人其实还并不是太多,如果您想入门一门后端语言我建议还是从node入手最好. 我也是最近开始学习node,来谈谈近期对node的学习的心得. 提到node首先就是要安装一大堆 ...