#P7885. 「MCOI-06」Flight
「MCOI-06」Flight
Description
Bookworm needs to move his tunnel boring machine.
Bookworm models the MC space as a 2D plane. His tunnel boring machine is currently at , and he wants to move it to .
In each step, Bookworm can move the machine one unit to the east, south, west, or north. However, the machine has a restriction: two consecutive steps cannot be taken in the same direction.
Given and , compute the minimum number of steps Bookworm needs to move the machine to the destination.
Output the minimum number of steps. It can be proven that he can always reach the destination.
Input Format
This problem contains multiple test cases.
The first line contains a positive integer , representing the number of test cases.
The next lines each contain four integers , representing one test case, where is the starting point and is the ending point.
Output Format
Output lines. The -th line should contain the answer for the -th test case.
3
-2 0 -2 1
0 1 3 3
-1 1 1 1
1
5
4
Hint
Explanation for Sample 1
- For the first test case, an optimal strategy is .
- For the second test case, an optimal strategy is $(0,1)\rarr(1,1)\rarr(1,2)\rarr(2,2)\rarr(2,3)\rarr(3,3)$.
- For the third test case, one optimal strategy is .
Constraints
This problem uses bundled testdata.
- Subtask 1 (29 pts): .
- Subtask 2 (29 pts): .
- Subtask 3 (42 pts): no special restrictions.
For all testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号