Catch
Limits: 2 sec., 512 MiB
This statement was translated automatically from Ukrainian.
Two players are playing a game on a plane. The second player wants to catch the first player, while the first player wants to reach one of the safe locations. The first player starts at a point with integer coordinates \((x_1, y_1)\). The second player is at a point with integer coordinates \((x_2, y_2)\).
In one second, a player moves to one of 4 adjacent points, that is, from the point \((x, y)\) to one of the points \((x+1, y)\), \((x-1, y)\), \((x, y+1)\), or \((x, y - 1)\). The players take turns, with the first player making a move in the first second, the second player in the next second, then the first player again, and so on. The first player cannot move to the point where the second player is located.
Safe points for the first player are points with \(x=0\) or \(y=0\). The first player wins if they move to one of these points. The second player wins if they move to the point containing the first player, or if the game does not end within \(10^{100}\) moves. In this case, the game ends immediately.
Determine whether the first player can reach a safe point.
Input
The first line contains a single integer \(t\) – the number of test cases.
Each of the following \(t\) lines contains 4 integers \(x_1, y_1, x_2, y_2\) – the initial positions of the players.
Output
For each of the \(t\) lines, output
YES if the first player can reach a safe point in the
corresponding test, and NO otherwise.
Constraints
\(1 \le t \le 10^5\),
\(-10^9 \le x_1, y_1, x_2, y_2 \le 10^9\),
\((x_1, y_1) \ne (x_2, y_2)\),
\(x_1 \ne 0, y_1 \ne 0\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 2 1 1 2 2 2 2 1 1 | YES NO |
Notes
In the first test case, it is sufficient for the first player to move to one of the points (1, 0) or (0, 1) on their first move to win. In the figure, the first player is represented by point \(A\), the second player by point \(B\), and all safe points are marked in red.
In the second test, if the first player moves left or down, the second player can catch them on the next move. If the first player only moves up or right, the second player can mirror their moves until the move limit is reached.
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|