No.1714 Tag on Grid
Problem Statement
nok0 and zkou play tag on a grid with $H$ rows and $W$ columns. The cell at the $i$-th row from the top and the $j$-th column from the left $(1 \le i \le H, 1 \le j \le W)$ is denoted by $(i, j)$. Initially, nok0 is at $(n_i, n_j)$ and zkou is at $(z_i, z_j)$.
In this game of tag, nok0 is the chaser and zkou runs away. During the game, the two take turns moving to one of the cells adjacent vertically or horizontally. nok0 moves first and zkou moves second. If nok0 and zkou are in the same cell at some moment, nok0 catches zkou and the game ends at that point.
nok0's goal is to catch zkou, and zkou's goal is to avoid being caught by nok0. nok0 and zkou each move optimally to achieve their respective goals.
Determine whether nok0 can catch zkou.
Print Yes if he can catch him,
and No if he cannot.
Constraints
- All input values are integers.
- $2 \le H \le 10^9$
- $2 \le W \le 10^9$
- $1 \le n_i \le H$
- $1 \le n_j \le W$
- $1 \le z_i \le H$
- $1 \le z_j \le W$
- $(n_i, n_j) \neq (z_i, z_j)$
Input
$H$ $W$ $n_i$ $n_j$ $z_i$ $z_j$
Output
Print Yes if nok0 can catch zkou,
and No if he cannot.
Sample
Sample 1
Input
2 3 1 1 2 3
Output
Yes
Here is one example of how the game may proceed. The moves described below are not necessarily optimal.
- nok0 moves to $(1, 2)$.
- zkou moves to $(2, 2)$.
- nok0 moves to $(2, 2)$. nok0 catches zkou.
Note that a player cannot stay in the same cell.
Sample 2
Input
2 2 1 1 2 2
Output
No
Sample 3
Input
1000000000 1000000000 1 1 1000000000 1000000000
Output
No
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
nok0