C - Convex Quadrilateral 解説 /

実行時間制限: 2 sec / メモリ制限: 1024 MB

配点 : 300

問題文

2 次元座標平面があります。x 軸正方向を右向き、y 軸正方向を上向きとします。

この平面上に自己交差のない四角形があります。
4 つの頂点の座標は反時計回りに (A_x,A_y),(B_x,B_y),(C_x,C_y),(D_x,D_y) です。

この四角形が凸であるか判定してください。

なお、四角形の 4 つの内角が全て 180 度未満であるとき、かつ、その時に限り、その四角形は凸であるといいます。

制約

  • -100 \leq A_x,A_y,B_x,B_y,C_x,C_y,D_x,D_y \leq 100
  • 入力に含まれる値は全て整数である
  • 与えられる 4 点は四角形の 4 頂点を反時計回りに並べたものである
  • 与えられる 4 点のなす四角形は自己交差がなく退化していない。すなわち
    • どの 2 頂点も同じ座標にない
    • どの 3 頂点も同一直線上にない
    • 隣接しない 2 辺は共有点を持たない

入力

入力は以下の形式で標準入力から与えられる。

A_x A_y
B_x B_y
C_x C_y
D_x D_y

出力

与えられる四角形が凸なら Yes、凸でないなら No を出力せよ。


入力例 1

0 0
1 0
1 1
0 1

出力例 1

Yes

与えられた四角形は正方形であり、4 つの内角は全て 90 度です。したがって、この四角形は凸です。

図


入力例 2

0 0
1 1
-1 0
1 -1

出力例 2

No

A270 度です。したがって、この四角形は凸ではありません。

図

Score : 300 points

Problem Statement

Consider a two-dimensional coordinate plane, where the x-axis is oriented to the right, and the y-axis is oriented upward.

In this plane, there is a quadrilateral without self-intersection.
The coordinates of the four vertices are (A_x,A_y), (B_x,B_y), (C_x,C_y), and (D_x,D_y), in counter-clockwise order.

Determine whether this quadrilateral is convex.

Here, a quadrilateral is convex if and only if all four interior angles are less than 180 degrees.

Constraints

  • -100 \leq A_x,A_y,B_x,B_y,C_x,C_y,D_x,D_y \leq 100
  • All values in input are integers.
  • The given four points are the four vertices of a quadrilateral in counter-clockwise order.
  • The quadrilateral formed by the given four points has no self-intersection and is non-degenerate. That is,
    • no two vertices are at the same coordinates;
    • no three vertices are colinear; and
    • no two edges that are not adjacent have a common point.

Input

Input is given from Standard Input in the following format:

A_x A_y
B_x B_y
C_x C_y
D_x D_y

Output

If the given quadrilateral is convex, print Yes; otherwise, print No.


Sample Input 1

0 0
1 0
1 1
0 1

Sample Output 1

Yes

The given quadrilateral is a square, whose four interior angles are all 90 degrees. Thus, this quadrilateral is convex.

Figure


Sample Input 2

0 0
1 1
-1 0
1 -1

Sample Output 2

No

The angle A is 270 degrees. Thus, this quadrilateral is not convex.

Figure