#K90642. Determine the Shape from Side Lengths
Determine the Shape from Side Lengths
Determine the Shape from Side Lengths
You are given four integers representing the lengths of the sides of a quadrilateral. Your task is to determine whether these sides can form a Square, a Rectangle (but not a square), or Neither.
The rules are as follows:
- If all four sides are equal, the shape is a Square.
- If the four sides can be grouped into two pairs of equal values (and the two distinct values are not equal), the shape is a Rectangle.
- Otherwise, the shape is Neither.
Mathematically, if the four sides are \(a, b, c, d\) and after sorting them as \(s_1 \le s_2 \le s_3 \le s_4\), then the condition for forming a rectangle (or square) is:
\[ s_1 = s_2 \quad \text{and} \quad s_3 = s_4 \]
If additionally \(s_1 = s_3\) then the shape is a square; otherwise it is a rectangle. In any other case, output "Neither".
inputFormat
The input is read from stdin and has the following format:
T a1 b1 c1 d1 ... aT bT cT dT
Where:
T
is the number of test cases.- Each test case consists of four integers that represent side lengths.
outputFormat
For each test case, output the determined shape on a separate line. The output is written to stdout and each line should be one of:
Square
Rectangle
Neither
1
4 4 4 4
Square