題解/算法 {376. 机器任务}
@LINK: https://www.acwing.com/problem/content/378/
;
比如一个任务是(ai, bj)
, 你把ai,bi
当作是一个二分图 ai
是左侧点, 然后把一个任务 当作是ai-bj
这条边, 那么问题就转换为: 选择最少的点 覆盖所有的边 即最小点覆盖;
Solution
Let the mode of two machines are [ 0 , . . . , A ) , [ 0 , . . . , B ) [0,...,A), [0,...,B) [0,...,A),[0,...,B), if we remove all tasks ( a , b ) (a,b) (a,b) whose a / b = 0 a/b = 0 a/b=0, then the problems becomes that choose as least as possible modes from [ 1 , . . . , A ) , [ 1 , . . . , B ) [1,...,A), [1, ..., B) [1,...,A),[1,...,B) such that they covers all tasks.
--
Let’s see a wrong Greed-Method, there are A − 1 + B − 1 A-1+B-1 A−1+B−1 modes, each time we choose a mode which covers the maximal count of tasks;
--
In fact, this is template-problem, if we transform a task
a
∈
[
1
,
A
)
,
b
∈
[
1
,
B
)
a \in [1,A) ,b \in [1, B)
a∈[1,A),b∈[1,B) to a Undirected-Edge
(
a
−
b
1
)
(a-b1)
(a−b1) where
b
1
=
b
+
A
b1 = b +A
b1=b+A (i.e., all machine-modes-id of two machines are distinct), now we get a undirected-graph
G
G
G; then our goal to choose at least points to cover all edges; that is find the Minimum Point Coverage of
G
G
G;
Moreover, cuz
G
G
G is also a Bipartite (making all points which
<
A
< A
<A be the
L
L
L-Set, and others be
R
R
R-Set), so it corresponds to the Minimum-Point-Coverage in a Bipartite;