欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1428A.Box is Pull
Box is Pull
Wabbit is trying to move a box containing food for the rest of the zoo in the coordinate plane from the point to the point .
He has a rope, which he can use to pull the box. He can only pull the box if he stands exactly unit away from the box in the direction of one of two coordinate axes. He will pull the box to where he is standing before moving out of the way in the same direction by unit.

For example, if the box is at the point and Wabbit is standing at the point , he can pull the box right by unit, with the box ending up at the point and Wabbit ending at the point .
Also, Wabbit can move unit to the right, left, up, or down without pulling the box. In this case, it is not necessary for him to be in exactly unit away from the box. If he wants to pull the box again, he must return to a point next to the box. Also, Wabbit can't move to the point where the box is located.
Wabbit can start at any point. It takes second to travel unit right, left, up, or down, regardless of whether he pulls the box while moving.
Determine the minimum amount of time he needs to move the box from to . Note that the point where Wabbit ends up at does not matter.
Input
Each test contains multiple test cases. The first line contains a single integer : the number of test cases. The description of the test cases follows.
Each of the next lines contains four space-separated integers , describing the next test case.
Output
For each test case, print a single integer: the minimum time in seconds Wabbit needs to bring the box from to .
Note
In the first test case, the starting and the ending points of the box are and respectively. This is the same as the picture in the statement. Wabbit needs only second to move as shown in the picture in the statement.
In the second test case, Wabbit can start at the point . He pulls the box to while moving to . He then moves to and then to without pulling the box. Then, he pulls the box to while moving to . It takes seconds.
Samples
2
1 2 2 2
1 1 2 2
1
4
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |