Score : $500$ points
Jumbo Takahashi will play golf on an infinite two-dimensional grid.
The ball is initially at the origin $(0, 0)$, and the goal is a grid point (a point with integer coordinates) $(X, Y)$. In one stroke, Jumbo Takahashi can perform the following operation:
The game is finished when the ball reaches the goal, and the score will be the number of strokes so far. Jumbo Takahashi wants to finish the game with the lowest score possible.
Determine if the game can be finished. If the answer is yes, find one way to bring the ball to the goal with the lowest score possible.
The Manhattan distance between two points $(x_1, y_1)$ and $(x_2, y_2)$ is defined as $|x_1-x_2|+|y_1-y_2|$.What is Manhattan distance?
Input is given from Standard Input in the following format:
$K$ $X$ $Y$
If the game cannot be finished, print -1
.
If the game can be finished, print one way to bring the ball to the destination with the lowest score possible, in the following format:
$s$ $x_1$ $y_1$ $x_2$ $y_2$ $.$ $.$ $.$ $x_s$ $y_s$
Here, $s$ is the lowest score possible, and $(x_i, y_i)$ is the position of the ball just after the $i$-th stroke.
11 -1 2
3 7 4 2 10 -1 2
Thus, this play is valid.
Also, there is no way to finish the game with less than three strokes.
4600 52 149
-1
4 9 9
5 1 3 4 2 4 6 6 8 9 9