Bishop Tour
InterviewTime limit1sMemory limit512 MB
Given a board and two squares, decide whether a bishop can travel from the start square to the end square using any number of diagonal moves.
- Level
Easy2 of 10
- Topics
- Math, Implementation, Geometry
- Solved
- No attempts yet
Problem
A knight's tour is a problem of finding a path on a chessboard where a knight visits every square exactly once. Chess master Heeja wondered whether the bishop, another minor piece, can also travel freely across the board. Given a start point and an end point, determine whether the bishop can move from the start point to the end point using as many moves as needed.
A bishop moves any number of squares diagonally in a single move.
Input
The first line gives the board dimensions and .
The second line gives the coordinates of the start point .
The third line gives the coordinates of the end point .
The top-left corner of the board has coordinates , and the bottom-right corner has coordinates .
Output
Print YES if the bishop can move from the start point to the end point, or NO otherwise.