#P7558. Maximizing the Minimal Turning Angle
Maximizing the Minimal Turning Angle
Maximizing the Minimal Turning Angle
Given N points in the Cartesian plane with coordinates \((X_i,Y_i)\), you are to determine an ordering (permutation) of these points such that when connecting consecutive points with straight lines, the minimum turning angle formed at every intermediate point is as large as possible.
More formally, if the points are visited in the order \(P_1, P_2, \ldots, P_N\), then at every intermediate point \(P_i\) (for \(2 \le i \le N-1\)) a turning angle \(\alpha_i\) is formed between the segment \(P_{i-1}P_i\) and \(P_iP_{i+1}\). Note that \(\alpha_i\) is defined as the smaller angle (\(\le 180^\circ\)) between the two segments.
Your task is to maximize the value
$$\max_{\text{permutation}} \min_{i=2}^{N-1}\{\alpha_i\}, $$and output the maximum possible minimal turning angle (in degrees) that can be achieved by some ordering.
Note: If \(N < 3\), there are no turning angles, so you may output 180
directly.
inputFormat
The first line contains an integer \(N\) (the number of points). \(N\) is guaranteed to be at least 1. Following this, there are \(N\) lines, each containing two space‐separated integers \(X_i\) and \(Y_i\), representing the coordinates of the \(i\)th point.
outputFormat
Output a single floating-point number: the maximum possible minimal turning angle (in degrees) achievable by some ordering. The output should be precise (for example, 8 decimal places).
sample
3
0 0
1 0
1 1
135.00000000