RectangleCoveringEasy
SRM 629 · 2014-07-26 · by dreamoon
Problem Statement
There is a rectangular hole in the ground.
You are given the dimensions of this rectangle:
You have a rectangular board.
You are given its dimensions:
There are some rules you must follow when covering the hole:
- You may rotate the board, but you must place it so that the sides of the board are parallel to the sides of the hole.
- The board must cover the entire hole.
- All corners of the board must be strictly outside the hole. (That is, they are not allowed to lie on the boundary of the hole.)
If you can cover the hole using the board you have, return 1. Otherwise, return -1.
Constraints
- holeW, holeH, boardW, and boardH will be between 1 and 1,000,000,000, inclusive.
1 1 1 1 Returns: -1
The vertices of the board must not be on the boundary of the hole.
3 5 4 6 Returns: 1
One possibility is to place the board so that it extends over the hole by 0.5 on each side.
10 20 25 15 Returns: 1
Here we have to rotate the board by 90 degrees.
3 10 3 12 Returns: 1
1000000000 1000000000 1000000000 1000000000 Returns: -1
Submissions are judged against all 193 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class RectangleCoveringEasy with a public method int solve(int holeH, int holeW, int boardH, int boardW) · 193 test cases · 2 s / 256 MB per case