問題一覧 > 通常問題

No.1714 Tag on Grid

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 191
作問者 : zkou / テスター : nok0 ygussany
お気に入りにしたユーザー ProblemId : 7102 / 自分の提出
問題文最終更新日: 2021-10-10 13:00:54
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 319 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。