#P1863. One-Eyed Rabbit Carrot Feast
One-Eyed Rabbit Carrot Feast
One-Eyed Rabbit Carrot Feast
Taro has a special rabbit who, having only one left eye, is unable to make right turns when moving. One day, Taro lays out n carrots on a plane with positions \((x_i,y_i)\). It is guaranteed that for any pair of carrots, their \(x_i\) coordinates and their \(y_i\) coordinates are all distinct. Let carrot \(A(x_A,y_A)\) be the carrot with the smallest \(x\) coordinate (i.e. \(x_A = \min\{x_1,x_2,\dots,x_n\}\)). The one‐eyed rabbit begins at the point \((0,y_A)\) and moves straight toward carrot \(A\), eating it upon arrival. Then, after consuming a carrot, the rabbit chooses another uneaten carrot as its next target and proceeds directly toward it. However, while traveling the straight line between carrots, the rabbit must follow two rules:
- No right turns: If the rabbit’s previous move is represented by vector \(\vec{D}\) and the next move by vector \(\vec{E}\), then the turning angle must be nonnegative; formally, the cross product \(\vec{D} \times \vec{E} = D_xE_y-D_yE_x\) must satisfy \(\vec{D} \times \vec{E} \ge 0\) (a zero value means going straight).
- No self-intersections: The new segment must not intersect any segment from its previous path (except at the shared endpoint between consecutive segments).
Taro wonders: what is the maximum number of carrots the one‐eyed rabbit can eat following these rules? Note that the rabbit always starts by eating carrot \(A\), and any carrot once eaten cannot be revisited.
Note on geometry: For two line segments \(p_1p_2\) and \(p_3p_4\), their intersection is determined using the standard orientation tests. Shared endpoints between consecutive segments are allowed.
inputFormat
The first line contains an integer \(n\) (the number of carrots). Each of the next \(n\) lines contains two integers \(x_i\) and \(y_i\), representing the coordinates of the \(i\)-th carrot. It is guaranteed that all \(x_i\) are distinct and all \(y_i\) are distinct.
outputFormat
Output a single integer: the maximum number of carrots that the one‐eyed rabbit can eat following the given movement rules.
sample
3
2 1
3 2
4 3
3
</p>