#K14111. Collinearity Check

    ID: 24063 Type: Default 1000ms 256MiB

Collinearity Check

Collinearity Check

You are given a set of points in a 2D plane. Your task is to determine whether all these points lie on a single straight line (i.e., they are collinear).

A set of points ((x_1, y_1), (x_2, y_2), \dots, (x_n, y_n)) are collinear if for any three distinct points ((x_1,y_1)), ((x_2,y_2)), and ((x_3,y_3)), the following condition holds:

$$(y_3 - y_1) \times (x_2 - x_1) = (y_2 - y_1) \times (x_3 - x_1) $$

Note: If there are less than or equal to two points, they are considered collinear by definition.

inputFormat

The input is given via standard input (stdin) and consists of multiple lines. The first line contains an integer (n) ((1 \leq n \leq 10^5)), the number of points. Each of the next (n) lines contains two integers (x) and (y) representing the coordinates of a point. The coordinates are separated by a space.

outputFormat

Print a single line to standard output (stdout). Output "YES" if all points are collinear, otherwise output "NO".## sample

4
1 2
2 3
3 4
4 5
YES