hdoj 1150 Machine Schedule
来源:互联网 发布:图书cip数据查询 编辑:程序博客网 时间:2024/05/17 08:08
Machine Schedule
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6317 Accepted Submission(s): 3163
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.
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.
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 100 1 11 1 22 1 33 1 44 2 15 2 26 2 37 2 48 3 39 4 30
Sample Output
3
最小点覆盖数 = 最大匹配数
匈牙利算法:
#include<stdio.h>#include<string.h>#define max 1000+10int used[max],map[max][max],pipei[max];int x,y,k;int find(int p){ int i; for(i=0;i<y;i++) { if(used[i]==0&&map[p][i]) { used[i]=1; if(pipei[i]==0||find(pipei[i])) { pipei[i]=p; return 1; } } } return 0;}int main(){ int i,j,sum; int a,b,c; while(scanf("%d",&x)&&(x!=0)) { scanf("%d%d",&y,&k); memset(map,0,sizeof(map)); memset(pipei,0,sizeof(pipei)); while(k--) { scanf("%d%d%d",&a,&b,&c); if(b&&c)//状态为0不需要重启 map[b][c]=1; } sum=0; for(i=0;i<x;i++) { memset(used,0,sizeof(used)); if(find(i)) sum++; } printf("%d\n",sum); } return 0;}
0 0
- HDOJ 1150 Machine Schedule
- hdoj 1150 Machine Schedule
- HDOJ 1150 Machine Schedule
- hdoj 1150 Machine Schedule
- 【HDOJ 1150】Machine Schedule
- hdoj 1150 Machine Schedule
- hdu/hdoj 1150 Machine Schedule
- ACM HDOJ 1150 (Machine Schedule )
- HDOJ 1150 Machine Schedule解题报告
- HDOJ 1150 Machine Schedule 二分匹配
- HDOJ 题目1150 Machine Schedule(二分图最小点覆盖)
- LA-2523 & POJ-1325 & HDOJ-1150 Machine Schedule 解题报告
- hdoj--1150--Machine Schedule(最小点覆盖)
- HDOJ 1150 Machine Schedule (二分图最小点覆盖)
- hdu 1150 Machine Schedule
- hdu 1150 Machine Schedule
- hdu 1150 Machine Schedule
- HDU 1150 Machine Schedule
- 卡索拉是阿森纳本赛季表现最稳定的球员
- C#委托
- C#数据结构,集合
- JAVA5--Condition使用的好处--可以实现多路通信
- 在Eclipse中写Processing程序
- hdoj 1150 Machine Schedule
- PAT B1014或A1061 福尔摩斯的约会
- 第六章 一张白纸好作画—Canvas画布(3)
- windows 传递文件给linux(pscp.exe)
- Dex Loader] Unable to execute dex 问题
- 第六章 一张白纸好作画—Canvas画布(4)
- swift与OC之间不得不知道的21点
- Windows7 旗舰版睡眠后不能唤醒
- 第六章 一张白纸好作画—Canvas画布(5)