OneMorePoint
SRM 278 · 2005-12-19 · by Vedensky
Problem Statement
There are some rectangles on a plane. Determine whether a point exists such that above, below, to the left, and to the right of the point lies an interior point of a rectangle. This point must not lie inside or on the boundary of any of the given rectangles.
You are given a
Notes
- Point A(xa, ya) is above point B(xb, yb) if xa = xb and ya > yb.
- Point A(xa, ya) is below point B(xb, yb) if xa = xb and ya < yb.
- Point A(xa, ya) is to the left of point B(xb, yb) if xa < xb and ya = yb.
- Point A(xa, ya) is to the right of point B(xb, yb) if xa > xb and ya = yb.
Constraints
- rectangles will contain between 0 and 50 elements, inclusive.
- Each element of rectangles will be formatted as "X1 Y1 X2 Y2".
- X1, Y1, X2, and Y2 will each be an integer between 0 and 10000, inclusive, with no extra leading zeros.
- X2 will be greater than X1, and Y2 will be greater than Y1.
{"0 0 2 1", "2 0 3 2", "1 2 3 3", "0 1 1 3"}
Returns: "YES"
The given rectangles are shown in grey in this figure. Any white point will meet our requirements.
{"0 0 2 1", "2 0 3 2", "1 2 3 3", "0 1 1 3", "1 1 2 2"}
Returns: "NO"
{"0 0 2 1", "3 0 4 2", "2 3 4 4", "0 2 1 3"}
Returns: "NO"
{"0 0 100 1", "100 1 200 2", "0 0 1 100", "50 50 51 51"}
Returns: "YES"
{"1 1 1000 1000"}
Returns: "NO"
Submissions are judged against all 77 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class OneMorePoint with a public method string interiorPoint(vector<string> rectangles) · 77 test cases · 2 s / 256 MB per case