Do rooks hit each other?
In chess, rooks are able to move in a horizontal direction or in a vertical one. In one move, they can get to any other location on the board until reaching an obstacle or the end of the board. If there is another figure on the path, the rook hits the figure.
Having two rooks, we would like to know if they hit each other. Given the
r1
(row) and c1
(column) coordinates of the first rook, and r2
(row) and c2
(column) coordinates of the second rook, print Yes
if they hit each other, and No
otherwise.Input | Output |
1
2
5
2 | Yes |
Constraints
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB