POJ 1325 Machine schedine (二分图-最小点覆盖数=最大匹配边数)
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 will be terminated by a line containing a single zero.
Output
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
题解:最小点覆盖数==最大匹配边数
参考代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<vector>
#include<map>
using namespace std;
const int maxn=;
int n,m,k,ok[maxn];
bool a[maxn][maxn],vis[maxn]; bool Find(int x)
{
for(int i=;i<=m;i++)
{
if(a[x][i]&&!vis[i])
{
vis[i]=true;
if(!ok[i]||Find(ok[i]))
{
ok[i]=x;
return true;
}
}
}
return false;
}
int maxP()
{
int ans=;
memset(ok,,sizeof(ok));
for(int i=; i<=n; i++)
{
memset(vis,false,sizeof(vis));
if(Find(i)) ans++;
}
return ans;
}
int main()
{
int kase=;
while(scanf("%d",&n) && n)
{
scanf("%d%d",&m,&k);
memset(a,false,sizeof(a));
int x,y,z;
while(k--)
{
cin>>x>>y>>z;
a[y][z]=true;
}
int ans=maxP();
int cnt=;
printf("%d\n",ans);
}
return ;
}
POJ 1325 Machine schedine (二分图-最小点覆盖数=最大匹配边数)的更多相关文章
- POJ - 1325 Machine Schedule 二分图 最小点覆盖
		题目大意:有两个机器,A机器有n种工作模式,B机器有m种工作模式,刚開始两个机器都是0模式.假设要切换模式的话,机器就必须的重新启动 有k个任务,每一个任务都能够交给A机器的i模式或者B机器的j模式完 ... 
- POJ 1325 Machine Schedule(最小点覆盖)
		http://poj.org/problem?id=1325 题意: 两种机器A和B.机器A具有n种工作模式,称为mode_0,mode_1,...,mode_n-1,同样机器B有m种工作模式mode ... 
- poj  1325 Machine Schedule  解题报告
		题目链接:http://poj.org/problem?id=1325 题目意思:有 k 个作业,机器A有 n 个模式:0 ~ n-1,机器B 有 m 个模式:0~ m-1.每一个作业能运行在 A 的 ... 
- [POJ] 2226 Muddy Fields(二分图最小点覆盖)
		题目地址:http://poj.org/problem?id=2226 二分图的题目关键在于建图.因为“*”的地方只有两种木板覆盖方式:水平或竖直,所以运用这种方式进行二分.首先按行排列,算出每个&q ... 
- HDU - 1150 Machine Schedule(最小点覆盖数)
		1.有两台机器A和B以及N个需要运行的任务.A机器有n种不同的模式,B机器有m种不同的模式,而每个任务都恰好在一台机器上运行.如果它在机器A上运行,则机器A需要设置为模式xi,如果它在机器B上运行,则 ... 
- HDU - 1150 POJ - 1325 Machine Schedule 匈牙利算法(最小点覆盖)
		Machine Schedule As we all know, machine scheduling is a very classical problem in computer science ... 
- POJ训练计划3041_Asteroids(二分图/最小点覆盖=最大匹配)
		解题报告 http://blog.csdn.net/juncoder/article/details/38135053 题目传送门 题意: 给出NxN的矩阵,有M个点是障碍 每次仅仅能删除一行或者一列 ... 
- poj 1325 Machine Schedule 二分匹配,可以用最大流来做
		题目大意:机器调度问题,同一个任务可以在A,B两台不同的机器上以不同的模式完成.机器的初始模式是mode_0,但从任何模式改变成另一个模式需要重启机器.求完成所有工作所需最少重启次数. ======= ... 
- POJ 1325 Machine Schedule——S.B.S.
		Machine Schedule Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 13731 Accepted: 5873 ... 
随机推荐
- 009.Kubernetes二进制部署kube-apiserver
			一 部署master节点 1.1 master节点服务 kubernetes master 节点运行如下组件: kube-apiserver kube-scheduler kube-controlle ... 
- linux环境中,两个不同网段的机器互通
			linux环境中,两个不同网段的机器互通 人评论3690人阅读2019-11-18 14:50:21 环境如下: host1 单网卡 eth0 172.24.100.15/16 hos ... 
- R画图——分屏
			最近项目需求,用R画了一个九宫格的图,第一次画,将简化后的脚本呈现一下,不是有人说,既然做了,那就摆出来吧. *中文行为说明: args <- commandArgs(T) 调用命令行读取 fi ... 
- Angular 2的HTML5 pushState在ASP.NET Core上的解决思路
			Angular 2的HTML5 pushState在ASP.NET Core上的解决思路 正如Angular 2在Routing & Navigation中所提及的那样,Angular 2是推 ... 
- Mybatis批量事务处理
			/** * 批量提交数据 * @param sqlSessionFactory * @param mybatisSQLId SQL语句在Mapper XML文件中的ID * @param commit ... 
- 05-商品类别数据和VUE展示
			一.商品类别数据和VUE展示 1.商品类别数据接口 将商品类别数据展示出来,视图(views.py)代码如下: class CategoryViewset(mixins.ListModelMixin, ... 
- 建筑行业的新起之秀---BIM
			近年来,BIM在国家在建筑行业的推进下逐渐走近人们的视线,而且BIM技术是作为建筑领域的一项新技术行业发展的越来越好,在很多的建筑场景都用到了BIM建模.施工.运维以及BIM+GIS等以BIM为 ... 
- js数组和集合互转
			js数组和集合互转可用于去重: 数组转集合 var arr = [55, 44, 65]; var set = new Set(arr); console.log(set.size === arr ... 
- 万恶之源-python内容的进化
			1.整数:  int--计算和比较  整数可以进行的操作:  bit_length().计算整数在内存中占用的二进制码的长度 2.布尔值  bool 布尔值--用于条件使用  True 真 ... 
- [Odoo12基础教程]之开发过程中可能出现的问题
			可能出现的问题 更改代码后无变化 当你对代码进行更改之后,发现页面并没有变化,那么请尝试依次以下几种办法: 1.重启项目: 2.升级模块: 3.在开发者模式下刷新本地模块列表: 4.给data列表添加 ... 
