Machine Schedule
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 6701 Accepted Submission (s): 3358
Problem Descriptionas We all know, machine scheduling are a very classical problem in computer science and have 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 was machines a and B. Machine A have n kinds of working modes, which is called Mode_0, Mode_1, ..., mode_n-1, Likew Ise machine B has m kinds of working modes, MODE_0, Mode_1, ..., mode_m-1. At the beginning they is both work at Mode_0.
For k jobs given, each of the them can is processed in either one of the one of the both machines in particular mode. For example, job 0 can either is processed in machine A at mode_3 or in machine B at Mode_4, Job 1 can either be processed In machine A is mode_2 or in machine B at Mode_4, and so on. Thus, for Job I, the constraint can is represent as a triple (I, X, y), which means it can be processed either 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 is 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.
Inputthe input file for this program consists of several configurations. The first line of one configuration contains three positive integers:n, M (N, M <) and K (K < 1000). The following k lines give the constrains of the K jobs, each of which is a triple:i, X, Y.
The input would be terminated to a line containing a single zero.
Outputthe output should is one integer per line, which means the minimal times of restarting machine.
Sample INPUT5 5 100 1 11 1 22 1 33 1 44 2 1 5 2 2 6 2 3 7 2 4 8 3 3 9 4 3 0
Sample Output3 Maximum number of matches: the minimum vertex coverage when all vertices are connected by a line that is not duplicated 22 = = Maximum match number binary plot for minimum vertex coverage: that is, with the fewest number of vertices, each edge can be associated with at least one of the points
#include <stdio.h> #include <string.h> #define MAX 1100int map[max][max],vis[max],mode[max];int t,n,m;int Find (int x) {int i,j;for (i=0;i<m;i++) {if (map[x][i]&&vis[i]==0) {vis[i]=1;if (mode[i]==0| | Find (Mode[i])) {Mode[i]=x;return 1;}}} return 0;} int main () {int J,i,s,k;int x,y;while (scanf ("%d", &n), N) {memset (map,0,sizeof (map)); memset (mode,0,sizeof (mode)); scanf ("%d%d", &m,&k), while (k--) {scanf ("%d%d%d", &t,&x,&y), if (x&&y) map[x][y]=1;} S=0;for (i=0;i<n;i++) {memset (vis,0,sizeof (VIS)); if (find (i)) s++;} printf ("%d\n", s);} return 0;}
HDOJ 1150 Machine Schedule "Hungarian algorithm + minimum vertex overlay"