#CCBCMCHIN0000059. Tọa độ trên biên hình chữ nhật (Point on Rectangle Boundary)
Tọa độ trên biên hình chữ nhật (Point on Rectangle Boundary)
Point on Rectangle Boundary
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
An axis-aligned rectangle has corners (0,0), (W,0), (W,H), and (0,H), with positive W and H. Determine whether integer point (x,y) lies on one of its four closed edges; a point outside an edge segment is not on the boundary.
Input
One line contains four integer values W,H,x,y.
Output
Print YES if the point is on a rectangle edge and NO otherwise.
Subtasks
-
Subtask 1 (20 points): 1 <= W,H <= 100, and the point is guaranteed inside/on the rectangle.
-
Subtask 2 (30 points): 1 <= W,H <= 10^6 and -10^6 <= x,y <= 2*10^6.
-
Subtask 3 (50 points): 1 <= W,H <= 10^9 and -10^9 <= x,y <= 2*10^9.
Examples
Example 1
Input
5 3 5 2
Output
YES
Explanation
For this input, the case-specific computation and the required exact output are shown above. The point (5,2) is inside the closed rectangle and its x coordinate equals W, so it lies on the right edge.
Example 2
Input
5 3 5 4
Output
NO
Explanation
For this input, the case-specific computation and the required exact output are shown above. The point (5,4) is outside the rectangle because 4 exceeds H=3, despite x being W.