Machine Schedule
总提交:31 测试通过:5
描述
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.
输入
The input will be terminated by a line containing a single zero.
输出
The output should be one integer per line, which means the minimal times of restarting machine.
样例输入
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
样例输出
该博客讨论了一个经典的计算机科学问题——机器调度,特别是涉及两个机器A和B的2机器调度问题。每个机器有多种工作模式,任务可以在特定模式下在任一机器上完成。目标是通过调整任务顺序并分配合适的机器,以最小化机器重启的次数来完成所有任务。文章介绍了输入输出格式,并提供了一个基于匈牙利算法的解决方案示例。
13万+

被折叠的 条评论
为什么被折叠?



