CF685C.Optimal Point
省选/NOI-
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
When the river brought Gerda to the house of the Old Lady who Knew Magic, this lady decided to make Gerda her daughter. She wants Gerda to forget about Kay, so she puts all the roses from the garden underground.
Mole, who lives in this garden, now can watch the roses without going up to the surface. Typical mole is blind, but this mole was granted as special vision by the Old Lady. He can watch any underground objects on any distance, even through the obstacles and other objects. However, the quality of the picture depends on the Manhattan distance to object being observed.
Mole wants to find an optimal point to watch roses, that is such point with integer coordinates that the maximum Manhattan distance to the rose is minimum possible.
As usual, he asks you to help.
Manhattan distance between points (_x_1, _y_1, _z_1) and (_x_2, _y_2, _z_2) is defined as |_x_1 - _x_2| + |_y_1 - _y_2| + |_z_1 - _z_2|.
当河水将格尔达带到那位懂魔法的老妇人住所时,这位老妇人决定收格尔达为养女。为了使格尔达忘记凯伊,她把花园里所有的玫瑰都埋到了地下。
住在该花园里的鼹鼠如今无需浮出地面,便能观察这些玫瑰。普通的鼹鼠是盲的,但这位鼹鼠被老妇人赐予了特殊的视觉能力:它能在任意距离上观察任何地下物体,甚至能穿透障碍物及其他物体。然而,所成图像的质量取决于观察点到目标物体的曼哈顿距离(Manhattan distance)。
鼹鼠希望找到一个最优的观察点——即一个具有整数坐标的点,使得该点到所有玫瑰的最大曼哈顿距离尽可能小。
和往常一样,它请你帮忙。
点 (x1, y1, z1) 与点 (x2, y2, z2) 之间的曼哈顿距离定义为
∣x1−x2∣+∣y1−y2∣+∣z1−z2∣.
输入格式
The first line of the input contains an integer t t (1 ≤ t ≤ 100 000) — the number of test cases. Then follow exactly t blocks, each containing the description of exactly one test.
The first line of each block contains an integer n__i (1 ≤ n__i ≤ 100 000) — the number of roses in the test. Then follow n__i lines, containing three integers each — the coordinates of the corresponding rose. Note that two or more roses may share the same position.
It's guaranteed that the sum of all n__i doesn't exceed 100 000 and all coordinates are not greater than 1018 by their absolute value.
输入的第一行包含一个整数 t(1≤t≤100000)—— 表示测试用例的数量。随后恰好有 t 个块,每个块描述一个测试用例。
每个块的第一行包含一个整数 ni(1≤ni≤100000)—— 表示该测试用例中玫瑰的数量。接下来是 ni 行,每行包含三个整数 —— 对应玫瑰的坐标。注意:两朵或更多玫瑰可能位于同一位置。
保证所有 ni 的总和不超过 100000,且所有坐标的绝对值均不超过 1018。
输出格式
For each of t test cases print three integers — the coordinates of the optimal point to watch roses. If there are many optimal answers, print any of them.
The coordinates of the optimal point may coincide with the coordinates of any rose.
对于每组测试用例,输出三个整数——观看玫瑰的最优位置的坐标。如果存在多个最优解,输出其中任意一个即可。
最优位置的坐标可以与任意一朵玫瑰的坐标重合。
输入输出样例
输入#1
1 5 0 0 4 0 0 -4 0 4 0 4 0 0 1 1 1
输出#1
0 0 0
输入#2
2 1 3 5 9 2 3 5 9 3 5 9
输出#2
3 5 9 3 5 9
说明/提示
In the first sample, the maximum Manhattan distance from the point to the rose is equal to 4.
In the second sample, the maximum possible distance is 0. Note that the positions of the roses may coincide with each other and with the position of the optimal point.
在第一个样例中,该点到玫瑰的最大曼哈顿距离为 4。
在第二个样例中,可能的最大距离为 0。注意,玫瑰的位置可能彼此重合,也可能与最优位置重合。
输入解题思路,AI测评打分。不知道怎么写?