You are given a map of cities with roads connecting some of them, as well as the length of each road. You have to choose cities in which you will build schools, such that the distance from any city to the nearest city with a school is at most 10 miles, and so that the total number of schools is as small as possible.
题目要求用贪心找出一个解,并证明这个解并不是最优的。
第一反应是求 Minimal Spanning Tree,然后在 Tree 上任意取一个 Vertex,建一个学校,然后把这个节点可以覆盖的 Vertices 去掉,重复,直到没有未覆盖的 Vertex。但是想了以下觉得不对,然后又想是不是对每个 Vertex 作为起点做一次 Dijkstra shortest path,然后每做完一次,从起点建学校,逐步覆盖所有的,然后取所有情况下最优的。无论上述哪一种,都觉得有问题。顺便求教最优解应该怎么求。
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
https://www.v2ex.com/t/443578
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.