Covering the Floor
Time limit1sMemory limit1024 MB
Given an X by Y floor and two rotatable rectangular sheets, find a placement of one or two sheets that covers the floor without cutting or folding, or report that it is impossible.
- Level
Medium6 of 10
- Topics
- Geometry, Implementation, Brute force
- Solved
- No attempts yet
Problem
Mati is going to paint the ceiling of a room, and he needs to cover the floor so that paint drops do not stain it. For this he has two cardboard sheets. He will need them again later, so he does not want to cut or fold them. If one sheet can cover the whole floor, he does not use the second one.
The room and the sheets are all rectangles. The room is cm, the first sheet is cm, and the second sheet is cm.
Check whether the two sheets can cover the entire floor at once. Sheets may be rotated and may partly overlap each other, but they cannot extend past the edge of the floor. If covering is possible, find the placement of the sheets in the XY coordinate system, where the opposite corners of the room are and . If there are several placements, output any one of them.
Input
The first line contains two integers and separated by a space (). The second line contains and , the dimensions of the first sheet, and the third line contains and , the dimensions of the second sheet, in the same format ().
Output
If the floor cannot be covered as required, print 'EI SAA' on a single line.
If the solution uses two sheets, print four integers on each of two lines. The first line gives the lower-left corner , and the upper-right corner , of the first sheet. The second line gives the corners , , , of the second sheet.
If only the first sheet is used, print its corner coordinates on the first line and 'Z' on the second line. If only the second sheet is used, print 'Z' on the first line and the corner coordinates of the second sheet on the second line.