[TC SRM 662 div1 lev1] FoxesOfTheRoundTable
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[TC SRM 662 div1 lev1] FoxesOfTheRoundTable相关的知识,希望对你有一定的参考价值。
转载:http://codeforces.com/blog/entry/19151
Note: 将问题转化为寻找hamiltonian回路问题。证明过程值得一看。
Suppose the heights are sorted: h[0] <= h[1] <= h[2] ...
In one hand, we know the answer can‘t be smaller than max{x[i+2] — x[i]}. We can proof this in the following way: If abs(x[i]-x[j]) >= ans, we add an edge between i and j. We assume there is an i and ans < x[i+2]-x[i]. Then if the graph is connected, edges (i, i+1) and (i+1, i+2) will be bridege (since if x < i and y > i+2 then there is no edge between x and y.) It means this graph don‘t have a hamiltonian cycle, so we can‘t arrange these foxes around a round table.
In another hand, we know that we have a solution that ans = max{x[i+2]-x[i]}: x[0]-x[2]-x[4]-x[6]-...-n-...x[5]-x[3]-x[1]-x[0].
So we know this solution is optimal.
以上是关于[TC SRM 662 div1 lev1] FoxesOfTheRoundTable的主要内容,如果未能解决你的问题,请参考以下文章