#C9449. Polygon Type Checker

    ID: 53543 Type: Default 1000ms 256MiB

Polygon Type Checker

Polygon Type Checker

You are given a sequence of 2D points. Your task is to determine whether these points form a closed polygon and, if so, whether the polygon is convex or concave.

A polygon is valid if and only if it contains at least 3 points. If there are fewer than 3 points, output NO POLYGON.

For a valid polygon, compute the orientation for every three consecutive points using the following formula in \(\LaTeX\) format:

\[ val = (q_y - p_y) \times (r_x - q_x) - (q_x - p_x) \times (r_y - q_y) \]

The sign of val determines the orientation:

  • val = 0: points are collinear
  • val > 0: clockwise turn
  • val < 0: counterclockwise turn

If the directions of the turns are consistent, the polygon is CONVEX. If there is a mix of clockwise and counterclockwise turns, the polygon is CONCAVE.

Input is provided via standard input, and your program should output the result to standard output.

inputFormat

The first line contains an integer \(n\) representing the number of points. The second line contains \(2n\) space-separated integers corresponding to the x and y coordinates of the points in order.

Example:

4
0 0 0 3 3 3 3 0

outputFormat

Output a single line containing one of the following strings: NO POLYGON, CONVEX, or CONCAVE based on the type of polygon formed by the input points.

## sample
2
1 2 2 1
NO POLYGON