#C9414. Minimum Knight Moves
Minimum Knight Moves
Minimum Knight Moves
Given two space-separated integers \( x \) and \( y \), determine the minimum number of moves a knight requires to reach the point \( (x, y) \) starting from \( (0, 0) \) on an infinite chessboard. A knight moves in an L-shape: two squares in one direction and then one square perpendicular to that direction. Due to the symmetry of the chessboard, the problem can be simplified by taking the absolute values of \( x \) and \( y \).
The knight's legal moves are given by the set of vectors: \( \{(2,1),\ (1,2),\ (-2,1),\ (-1,2),\ (2,-1),\ (1,-2),\ (-2,-1),\ (-1,-2)\} \). Using a breadth-first search (BFS) algorithm, find the minimum number of moves required to reach the target coordinate.
inputFormat
The input consists of a single line containing two space-separated integers \( x \) and \( y \) which represent the target coordinates on the chessboard. Note that \( x \) and \( y \) can be either positive or negative.
outputFormat
Output a single integer representing the minimum number of knight moves required to travel from \( (0, 0) \) to \( (x, y) \).
## sample5 5
4
</p>