Make One Square
InterviewTime limit2sMemory limit512 MB
Given three rectangles that can each be rotated 90 degrees, decide whether they can tile one square exactly with no overlaps or gaps.
- Level
Medium5 of 10
- Topics
- Geometry, Implementation, Brute force, Math
- Solved
- No attempts yet
Problem
You are given three rectangles. Decide whether the three of them can be glued together, without overlapping, so that they fill exactly one square. Each rectangle may be rotated by 90 degrees, but it cannot be cut and it cannot be left out. The three areas together have to equal the area of the square.
For example, rectangles , and fill an square. The piece covers a full row at the top, and the and pieces sit side by side in the remaining region.

Input
The input consists of three lines.
The first line contains the width and the height of the first rectangle, separated by a space. ()
The second line contains the width and the height of the second rectangle. ()
The third line contains the width and the height of the third rectangle. ()
Output
Print on one line if the three rectangles can be put together to form a square, and if they cannot.