[Solution] The Attack of Knight CodeChef Solution
While playing chess, Chef noticed that it is generally advantageous for him if his knight attacks two or more of his opponent's pieces simultaneously. To practice this skill, Chef decided to perform the following exercise:
- Take an empty chessboard, and any two white pieces.
- Choose two distinct cells , and place the pieces on those cells (the cell at the intersection of the -th row and -th column is denoted ).
- Check if there exists an empty cell where he can place a black knight in such a way that the knight attacks both the white pieces simultaneously.
Given the position of the two white pieces , , print 'YES' if there exists an empty cell where he can place a black knight in such a way that the knight attacks both the white pieces simultaneously, otherwise print NO
.
For reference, a knight attacks a piece placed in a cell that is:
- One square horizontally and two squares vertically away from it, or
- One square vertically and two squares horizontally away from it
A visual description of this may be found here.
Input Format
- The first line of input will contain an integer — the number of test cases. The description of test cases follows.
- The first line of each test case contains two space-separated integers and , the position of first white piece.
- The second line of each test case contains two space-separated integers and , the position of second white piece.
Output Format
For each test case, output the answer on a new line — YES
if there exists an empty cell where Chef can place a black knight in such a way that the knight attacks both the white pieces simultaneously, and NO
otherwise.
You may print each character of YES
and NO
in either uppercase or lowercase (for example, yes
, yEs
, Yes
will be considered identical).
Constraints
- Both the cells are distinct
No comments:
Post a Comment