#K15206. Convex Polygon Checker
Convex Polygon Checker
Convex Polygon Checker
You are given several test cases. Each test case represents a polygon by a series of points provided in order. Your task is to determine if the polygon is convex.
A polygon is convex if for every three consecutive vertices \(p_1\), \(p_2\), and \(p_3\) the cross product \[ \text{cp} = (x_2 - x_1) (y_3 - y_1) - (y_2 - y_1)(x_3 - x_1) \] has the same sign for all sets (ignoring zeros). If the polygon has less than 3 vertices, it is not considered a valid polygon.
The input is read from standard input (stdin) and the output should be printed to standard output (stdout) with one result per test case.
inputFormat
The first line of input contains an integer \(T\) representing the number of test cases. Each test case follows:
- The first number is an integer \(N\) (number of points).
- Then follows \(N\) pairs of integers \(x\) and \(y\) representing the coordinates of each point in order.
All input is read from standard input (stdin).
outputFormat
For each test case, print "YES" if the points form a convex polygon, otherwise print "NO". Print each answer on a new line to standard output (stdout).
## sample3
4 0 0 0 1 1 1 1 0
5 0 0 2 2 4 0 3 3 1 3
3 0 0 1 2 2 0
YES
NO
YES
</p>