且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

攻击的最小数字所需

更新时间:2023-02-19 23:15:41

这可以看作是一个图的问题。

This can be modelled as a graph problem.

为每个行和列,其中有一个怪物的图的节点。 连接节点,如果一个怪物在该行和列。

Create a graph node for each row and column where there's a monster. Connect the nodes if a monster is on that row and that column.

这是一个二分图,你想要做的最小顶点覆盖。 柯尼希定理显示,对于二部图的问题是equivalnt具有最大匹配的问题,可以在polinomial时间来解决:

This is a bipartite graph, and you want to do minimum vertex cover. König's theorem shows that for bipartite graphs the problem is equivalnt with the maximum matching problem which can be solved in polinomial time:

http://en.wikipedia.org/wiki/Maximum_matching#Maximum_matchings_in_bipartite_graphs