Rectangle or Not

Hasinur_ Replay of CodeSpark 2021
Limits 1s, 512 MB

Let’s imagine a quadrant lies on a 2D coordinate system’s first quadrant. you will be given the coordinates of each vertex. Your task is to determine if it is an axis parallel, non-degenerate rectangle or not.

Axis parallel rectangle is a geometric shape which has sides parallel to axes of the coordinate system.

A rectangle is called non-degenerate if it is not deformed. Hence, there are no three vertices lying on the same straight line and the rectangle has a positive area. Read sample case explanation for better understanding.

Input

The first line of the input will contain a single integer TT (1T105)(1 \leq T \leq 10^5)which denotes the number of test cases. Then, there will be TT test cases.

Each of the next TT lines will contain eight positive integers separated by spaces, representing the coordinates of the vertices. To clarify things a little bit, let there be four vertices of the quadrant (x1,y1)(x_1, y_1), (x2,y2)(x_2, y_2), (x3,y3)(x_3, y_3), (x4,y4)(x_4, y_4) where 1xi,yi1051 \leq x_i, y_i \leq 10^5. Then the input will contain the coordinates in a single line like below:

x1x_1 y1y_1 x2x_2 y2y_2 x3x_3 y3y_3 x4x_4 y4y_4

Note that, the vertices will not be given in any particular order.

Output

For each test case, print “yes” without quotations if the given quadrant is an axis parallel, non-degenerate quadrilateral rectangle in a line. Print “no” otherwise. You can print each letter in any case. For example, “YeS”, ”YES”, “yES”, “no”, ”NO” etc. are also acceptable.

Sample

InputOutput
5
1 1 1 2 2 2 2 1
1 2 2 1 1 1 2 2
1 1 1 1 1 1 1 1
1 1 2 2 1 2 2 3
1 1 2 2 3 3 3 1
yes
yes
no
no
no

Explanation of the first test case:

The sides are parallel to the axes and there are no three vertices lying on the same straight line. The area is positive.

This is an axis parallel, non-degenerate rectangle.

Explanation of the fifth test case:

There are three vertices lying on the same straight line. So, this is not a non-degenerated rectangle.


Submit

Login to submit.

Statistics

65% Solution Ratio
Shatadal6666Earliest, Jul '21
bisnu_sarkarFastest, 0.0s
IshanXLightest, 393 kB
D3structorShortest, 362B
Toph uses cookies. By continuing you agree to our Cookie Policy.