CF1845B.Come Together
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Bob and Carol hanged out with Alice the whole day, but now it's time to go home. Alice, Bob and Carol live on an infinite 2D grid in cells A, B, and C respectively. Right now, all of them are in cell A.
If Bob (or Carol) is in some cell, he (she) can move to one of the neighboring cells. Two cells are called neighboring if they share a side. For example, the cell (3,5) has four neighboring cells: (2,5), (4,5), (3,6) and (3,4).
Bob wants to return to the cell B, Carol — to the cell C. Both of them want to go along the shortest path, i. e. along the path that consists of the minimum possible number of cells. But they would like to walk together as well.
What is the maximum possible number of cells that Bob and Carol can walk together if each of them walks home using one of the shortest paths?
鲍勃和卡罗尔与爱丽丝一起玩了一整天,但现在是回家的时候了。爱丽丝、鲍勃和卡罗尔分别住在无限二维网格上的格子 A、B 和 C 中。此时,他们三人都位于格子 A。
若鲍勃(或卡罗尔)处于某个格子中,则他(她)可以移动到其相邻格子之一。若两个格子共享一条边,则称它们为相邻格子。例如,格子 (3,5) 有四个相邻格子:(2,5)、(4,5)、(3,6) 和 (3,4)。
鲍勃希望返回格子 B,卡罗尔希望返回格子 C。他们都希望沿最短路径行走,即经过的格子数最少的路径。但他们也希望尽可能多地结伴同行。
若鲍勃和卡罗尔各自选择一条最短路径回家,那么他们最多能共同经过多少个格子?
输入格式
The first line contains the single integer t (1≤t≤104) — the number of test cases.
The first line of each test case contains two integers xA and yA (1≤xA,yA≤108) — the position of cell A, where both Bob and Carol are right now.
The second line contains two integers xB and yB (1≤xB,yB≤108) — the position of cell B (Bob's house).
The third line contains two integers xC and yC (1≤xC,yC≤108) — the position of cell C (Carol's house).
Additional constraint on the input: the cells A, B, and C are pairwise distinct in each test case.
第一行包含一个整数 t(1≤t≤104)——测试用例的数量。
每个测试用例的第一行包含两个整数 xA 和 yA(1≤xA,yA≤108)——表示单元格 A 的位置,Bob 和 Carol 当前均位于此处。
第二行包含两个整数 xB 和 yB(1≤xB,yB≤108)——表示单元格 B 的位置(Bob 的家)。
第三行包含两个整数 xC 和 yC(1≤xC,yC≤108)——表示单元格 C 的位置(Carol 的家)。
输入的额外约束:在每个测试用例中,单元格 A、B 和 C 两两互不相同。
输出格式
For each test case, print the single integer — the maximum number of cells Bob and Carol can walk together if each of them goes home along one of the shortest paths.
对于每个测试用例,输出一个整数——即如果鲍勃和卡罗尔各自沿着一条最短路径回家,他们可以共同经过的最多格子数。
输入输出样例
输入#1
3 3 1 1 3 6 4 5 2 2 2 7 2 1 1 4 3 5 5
输出#1
3 1 6
说明/提示
In all pictures, red color denotes cells belonging only to Bob's path, light blue color — cells belonging only to Carol's path, and dark blue color — cells belonging to both paths.
One of the optimal routes for the first test case is shown below:

Bob's route contains 5 cells, Carol's route — 7 cells, and they will visit 3 cells together.
The optimal answer for the second test case is shown below:

Bob's route contains 4 cells, Carol's route — 3 cells, and they will visit only 1 cell together.
One of the optimal answers for the third test case is shown below:

Bob's route contains 6 cells, Carol's route — 9 cells, and they will visit 6 cells together.
在所有图片中,红色表示仅属于鲍勃路径的单元格,浅蓝色表示仅属于卡罗尔路径的单元格,深蓝色表示同时属于两条路径的单元格。
第一个测试用例的一种最优路径如下所示:

鲍勃的路径包含 5 个单元格,卡罗尔的路径包含 7 个单元格,他们将共同访问 3 个单元格。
第二个测试用例的最优答案如下所示:

鲍勃的路径包含 4 个单元格,卡罗尔的路径包含 3 个单元格,他们仅共同访问 1 个单元格。
第三个测试用例的一种最优答案如下所示:

鲍勃的路径包含 6 个单元格,卡罗尔的路径包含 9 个单元格,他们将共同访问 6 个单元格。
输入解题思路,AI测评打分。不知道怎么写?