307873: CF1428A. Box is Pull
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Box is Pull
题意翻译
有一个兔子拖着一个盒子在走,每秒钟可以带着盒子走一个单位,也可以不带着盒子走一个单位。当且仅当兔子和盒子的距离不超过 $1$ 时可以带着盒子走一个单位。现给出 $t$ 次询问,每次询问给出四个整数 $x_1,y_1,x_2,y_2$,试求出将盒子从 $(x_1,y_1)$ 拖到 $(x_2,y_2)$ 最少需要多少秒。 **数据范围:$1\leqslant t\leqslant 1000,1\leqslant x_1,y_1,x_2,y_2\leqslant 10^9$。**题目描述
Wabbit is trying to move a box containing food for the rest of the zoo in the coordinate plane from the point $ (x_1,y_1) $ to the point $ (x_2,y_2) $ . He has a rope, which he can use to pull the box. He can only pull the box if he stands exactly $ 1 $ 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 $ 1 $ unit. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1428A/2422508128accdddeba8587f2e8100615540e6d2.png)For example, if the box is at the point $ (1,2) $ and Wabbit is standing at the point $ (2,2) $ , he can pull the box right by $ 1 $ unit, with the box ending up at the point $ (2,2) $ and Wabbit ending at the point $ (3,2) $ . Also, Wabbit can move $ 1 $ 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 $ 1 $ 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 $ 1 $ second to travel $ 1 $ 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 $ (x_1,y_1) $ to $ (x_2,y_2) $ . Note that the point where Wabbit ends up at does not matter.输入输出格式
输入格式
Each test contains multiple test cases. The first line contains a single integer $ t $ $ (1 \leq t \leq 1000) $ : the number of test cases. The description of the test cases follows. Each of the next $ t $ lines contains four space-separated integers $ x_1, y_1, x_2, y_2 $ $ (1 \leq x_1, y_1, x_2, y_2 \leq 10^9) $ , describing the next test case.
输出格式
For each test case, print a single integer: the minimum time in seconds Wabbit needs to bring the box from $ (x_1,y_1) $ to $ (x_2,y_2) $ .
输入输出样例
输入样例 #1
2
1 2 2 2
1 1 2 2
输出样例 #1
1
4