No.3154 convex polygon judge
Problem Statement
There are $N$ points at distinct positions on a $2$-dimensional coordinate plane, and the coordinates of the $i$-th point $(1 \leq i \leq N)$ are $(X_i,Y_i)$.
Initially, not even $1$ line segment is drawn. Determine whether it is possible to form a strictly convex $N$-gon by repeating $N$ times the operation of choosing $2$ distinct points appropriately and connecting them with a line segment.
What is a strictly convex $N$-gon?
An $N$-gon $(3 \leq N)$ in which every interior angle is less than $180$ degrees is called a strictly convex $N$-gon. Be careful about cases where there is a vertex whose interior angle is $180$ degrees.Constraints
- $3 \leq N \leq 2 \times 10^{5}$
- $0 \leq X_i,Y_i \leq 10^9 (1 \leq i \leq N)$
- $i \neq j \Rightarrow (X_i,Y_i) \neq (X_j,Y_j)$
- All inputs are integers.
Input
$N$ $X_1$ $Y_1$ $X_2$ $Y_2$ $\vdots$ $X_N$ $Y_N$
Output
Print Yes if a strictly convex $N$-gon can be formed, and No otherwise.
Sample
Sample 1
Input
4 0 0 4 0 3 3 0 4
Output
Yes
Connecting point $1$ and point $4$, point $4$ and point $3$, point $3$ and point $2$, and point $2$ and point $1$ forms a convex $4$-gon. Therefore, print Yes.
Sample 2
Input
4 0 0 1 1 4 0 0 4
Output
No
No matter how the lines are drawn, a convex $4$-gon cannot be formed. Therefore, print No.
Sample 3
Input
5 0 0 2 0 4 0 3 3 0 4
Output
No
Connecting point $1$ and point $2$, point $2$ and point $3$, point $3$ and point $4$, point $4$ and point $5$, and point $5$ and point $1$ forms a convex polygon. However, since point $1$, point $2$, and point $3$ lie on a straight line, point $2$ cannot be regarded as a vertex of a $5$-gon, so this is a convex $4$-gon.
Other than this, no matter how the line segments are drawn, a convex $5$-gon cannot be formed. Therefore, print No.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
Cafe1942
kazuppa