303543: CF685C. Optimal Point

Memory Limit:256 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Optimal Point

题意翻译

### 题目描述 给定一个立体直角坐标系上的$n$个整点,求一个整点满足到这$n$个整点的曼哈顿距离的最大值最小。 ### 输入格式 第一行一个正整数$t(1 \leq t \leq 10^5)$表示数据组数 接下来$t$组数据每组数据第一行一个正整数$n(1 \leq n , \sum n \leq 10^5)$表示点数,接下来$n$行每行三个整数$x_i,y_i,z_i(-10^{18} \leq x_i,y_i,z_i \leq 10^{18})$描述一个整点。 ### 输出格式 对于每组测试数据输出一行三个整数表示选出的整点。

题目描述

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}| $ .

输入输出格式

输入格式


The first line of the input contains an integer $ t $ $ t $ ( $ 1<=t<=100000 $ ) — 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}<=100000 $ ) — 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 $ 100000 $ and all coordinates are not greater than $ 10^{18} $ by their absolute value.

输出格式


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.

Input

题意翻译

### 题目描述 给定一个立体直角坐标系上的$n$个整点,求一个整点满足到这$n$个整点的曼哈顿距离的最大值最小。 ### 输入格式 第一行一个正整数$t(1 \leq t \leq 10^5)$表示数据组数 接下来$t$组数据每组数据第一行一个正整数$n(1 \leq n , \sum n \leq 10^5)$表示点数,接下来$n$行每行三个整数$x_i,y_i,z_i(-10^{18} \leq x_i,y_i,z_i \leq 10^{18})$描述一个整点。 ### 输出格式 对于每组测试数据输出一行三个整数表示选出的整点。

加入题单

上一题 下一题 算法标签: