#K74597. Point on a Line Segment

    ID: 34232 Type: Default 1000ms 256MiB

Point on a Line Segment

Point on a Line Segment

Given three points with integer coordinates, determine if the third point lies on the line segment defined by the first two points. The point is considered to lie on the segment if it is collinear with the segment endpoints and it lies within the bounding box of the endpoints.

The collinearity condition can be mathematically expressed as: ( (y_3 - y_1)(x_2 - x_1) = (y_2 - y_1)(x_3 - x_1) ).

If the condition holds and the third point is between the endpoints (inclusive) in both x and y directions, then output "Yes"; otherwise output "No".

Constraints:
 -1000 ≤ x1, y1, x2, y2, x3, y3 ≤ 1000.
Note that the two endpoints of the segment will be distinct.

inputFormat

The input consists of a single line containing six space-separated integers: x1, y1, x2, y2, x3, y3.

outputFormat

Output a single line containing "Yes" if the third point lies on the line segment between (x1, y1) and (x2, y2); otherwise, output "No".## sample

1 1 3 3 2 2
Yes