题库练习 Optimal Point
← 上一题 下一题 →

A10390 | Optimal Point

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

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
C++ 编辑器
输入
输出