AtCoder Regular Contest 109
D
L
AtCoder
⌀ 2394
原题
← CE →
翻译中…

Problem Statement

翻译中…

We have three stones at points $(0, 0)$, $(1,0)$, and $(0,1)$ on a two-dimensional plane.

翻译中…

These three stones are said to form an L when they satisfy the following conditions:

翻译中…
  • Each of the stones is at integer coordinates.
  • Each of the stones is adjacent to another stone. (That is, for each stone, there is another stone whose distance from that stone is $1$.)
  • The three stones do not lie on the same line.
翻译中…

Particularly, the initial arrangement of the stone - $(0, 0)$, $(1,0)$, and $(0,1)$ - forms an L.

翻译中…

You can do the following operation any number of times: choose one of the stones and move it to any position. However, after each operation, the stones must form an L. You want to do as few operations as possible to put stones at points $(ax, ay)$, $(bx, by)$, and $(cx, cy)$. How many operations do you need to do this?

翻译中…

It is guaranteed that the desired arrangement of stones - $(ax, ay)$, $(bx, by)$, and $(cx, cy)$ - forms an L. Under this condition, it is always possible to achieve the objective with a finite number of operations.

翻译中…

You will be given $T$ cases of this problem. Solve each of them.

翻译中…

Note

翻译中…

We assume that the three stones are indistinguishable. For example, the stone that is initially at point $(0,0)$ may be at any of the points $(ax, ay)$, $(bx, by)$, and $(cx, cy)$ in the end.

翻译中…

Constraints

翻译中…
  • $1 \leq T \leq 10^3$
  • $|ax|,|ay|,|bx|,|by|,|cx|,|cy| \leq 10^9$
  • The desired arrangement of stones - $(ax, ay)$, $(bx, by)$, and $(cx, cy)$ - forms an L.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

T
\text{case}_1
\vdots
\text{case}_T

翻译中…

Each case is in the following format:

翻译中…

ax ay bx by cx cy

翻译中…

Output

翻译中…

Print $T$ values. The $i$-th value should be the minimum number of operations for $\text{case}_i$.

翻译中…

样例

Input #1
1
3 2 2 2 2 1
Output #1
4
Let us use `#` to represent a stone. You can move the stones to the specified positions with four operations, as follows:
Input #2
10
0 0 1 0 0 1
1 0 0 1 1 1
2 -1 1 -1 1 0
1 -2 2 -1 1 -1
-1 2 0 2 -1 3
-1 -2 -2 -2 -2 -3
-2 4 -3 3 -2 3
3 1 4 2 4 1
-4 2 -4 3 -3 3
5 4 5 3 4 4
Output #2
0
1
2
3
4
5
6
7
8
9
题目信息
题号
arc109_d
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。