#abc323f. F - Push and Carry
F - Push and Carry
Score : points
问题描述
高桥和一件货物在一个坐标平面上。
目前,高桥位于坐标 ,而货物位于坐标 。他希望将货物移动到坐标 。
当他在坐标 时,他可以在一个动作中执行以下四种移动之一:
- 移动到 。如果在移动前货物位于 ,则将其移动到 。
- 移动到 。如果在移动前货物位于 ,则将其移动到 。
- 移动到 。如果在移动前货物位于 ,则将其移动到 。
- 移动到 。如果在移动前货物位于 ,则将其移动到 。
求解将货物移动到 所需的最小动作次数。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Takahashi and a cargo are on a coordinate plane.
Takahashi is currently at , and the cargo is at . He wants to move the cargo to .
When he is at , he can make one of the following moves in a single action.
- Move to . If the cargo is at before the move, move it to .
- Move to . If the cargo is at before the move, move it to .
- Move to . If the cargo is at before the move, move it to .
- Move to . If the cargo is at before the move, move it to .
Find the minimum number of actions required to move the cargo to .
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the minimum number of actions required to move the cargo to .
Sample Input 1
1 2 3 3 0 5
Sample Output 1
9
Takahashi can move the cargo to in nine actions as follows.
- Move to .
- Move to .
- Move to . The cargo moves to .
- Move to . The cargo moves to .
- Move to .
- Move to .
- Move to . The cargo moves to .
- Move to . The cargo moves to .
- Move to . The cargo moves to .
It is impossible to move the cargo to in eight or fewer actions, so you should print .
Sample Input 2
0 0 1 0 -1 0
Sample Output 2
6
Sample Input 3
-100000000000000000 -100000000000000000 100000000000000000 100000000000000000 -100000000000000000 -100000000000000000
Sample Output 3
800000000000000003
update @ 2024/3/10 01:45:18