P27858 [洛谷] [Language Month Competition 202308] Does Pink Rabbit Like Playing Chess?
普及-
题目描述

Problem Description

In Chinese chess, a horse moves in an "日" shape. Using $(i,j)$ to represent the grid point in the $i$-th row and $j$-th column, considering the possibility of jumping out of the chessboard, a horse at $(i,j)$ can jump to $(i-2,j+1)$, $(i-2,j-1)$, $(i-1,j+2)$, $(i-1,j-2)$, $(i+1,j+2)$, $(i+1,j-2)$, $(i+2,j+1)$, and $(i+2,j-1)$.

"Checking the general" is a common offensive strategy in Chinese chess. As shown in the figure below, the red general is at $(1,5)$ and the red chariot is at $(2,8)$. If the black horse jumps to the position indicated by the red box at $(3,6)$, the general will be forced to move, and at this point, the horse can capture the red chariot.

This problem will address a simplified version of the "checking the general" strategy. In this problem, "checking the general" means to jump the horse in one move to a position where it can check the general and place the chariot within the horse's attack range simultaneously.

Considering only the scenario where there is one red general, one red chariot, and one black horse on the board, without considering whether the general can protect the chariot by moving, and without considering blocking the horse's leg, in the current situation, when it is black's turn to move, can the black horse move in one step, without going out of bounds, to achieve "checking the general" and capturing the chariot?

Input Format

The input consists of three lines.

The first line contains two integers $S_x, S_y$, representing the position of the red general at $(S_x, S_y)$.

The second line contains two integers $C_x, C_y$, representing the position of the red chariot at $(C_x, C_y)$.

The third line contains two integers $M_x, M_y$, representing the position of the black horse at $(M_x, M_y)$.

It is guaranteed that the red general is within the nine-grid palace on rows $1$ to $3$.

Output Format

Output a single line containing a string:

  • If it is possible to achieve "checking the general" and capturing the chariot, output Yes.
  • If it is not possible to achieve "checking the general" and capturing the chariot, output No.

Sample Input and Output

Sample Input #1

1 5
2 8
5 5

Sample Output #1

Yes

Sample Input #2

1 5
2 9
5 5

Sample Output #2

No

Notes

Data Size and Constraints

For $100\%$ of the test data, $1 \le S_x \le 3$, $4 \le S_y \le 6$, $1 \le C_x, M_x \le 10$, $1 \le C_y, M_y \le 9$. It is guaranteed that no two pieces start at the same position.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
1 5 2 8 5 5
样例输出
Yes