Title Link: http://poj.org/problem?id=1325
As we all know, machine scheduling are a very classical problem in computer science and have been studied for a very long hi Story. 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, lik Ewise 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.
Title Description: There are now two machines A and b,a machines have n mode (0~n-1), B machine has M mode (0~m-1), the current AB machine is in mode 0. Given k work, each job either causes machine A to change the mode to I, or the machine B changes the mode to J. Every time the machine changes mode, it needs to reboot, asking the minimum number of restarts after K work is completed.
Algorithm analysis: First of all know that this is a binary graph.
Give such a set of data: k=n=m=3
Work 1 can change a to 1, change B to 2, work 2 to change a to 1, change B to 1, work 3 to change a to 1, change B to 0.
Then we just need to reboot once: change a from 0 to 1.
So I thought that the problem can be done with the smallest point coverage.
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cstdlib>5#include <cmath>6#include <algorithm>7 #defineINF 0x7fffffff8 using namespacestd;9 Const intmaxn= -+Ten;Ten One intn,m,k; A intG[MAXN][MAXN],LINKER[MAXN]; - intVIS[MAXN]; - the intDfsintu) - { - for(intv=1; v<m; v++)if(G[u][v]) - { + if(!Vis[v]) - { +vis[v]=1; A if(linker[v]==-1||DFS (Linker[v])) at { -linker[v]=u; - return 1; - } - } - } in return 0; - } to + intHungary () - { the intans=0; * for(intI=1; i<n; i++.) $ {Panax Notoginsengmemset (Vis,0,sizeof(Vis)); - if(Dfs (i)) ans++; the } + returnans; A } the + intMain () - { $ while(SCANF ("%d", &n)!=eof &&N) $ { -scanf"%d%d",&m,&k); -Memset (G,0,sizeof(g)); thememset (linker,-1,sizeof(linker)); -g[0][0]=1;Wuyi intj,a,b; the while(k--) - { Wuscanf"%d%d%d",&j,&a,&b); -g[a][b]=1; About } $printf"%d\n", Hungary ()); - } - return 0; -}
POJ 1325 Machine Schedule minimum point coverage