CF685C.Optimal Point

普及/提高-

通过率:0%

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 (x1, y1, z1)(x_{1}, y_{1}, z_{1}) and (x2, y2, z2)(x_{2}, y_{2}, z_{2}) is defined as x1x2+y1y2+z1z2|x_{1}-x_{2}|+|y_{1}-y_{2}|+|z_{1}-z_{2}| .

输入格式

The first line of the input contains an integer tt tt ( 1<=t<=1000001<=t<=100000 ) — the number of test cases. Then follow exactly tt blocks, each containing the description of exactly one test.

The first line of each block contains an integer nin_{i} ( 1<=ni<=1000001<=n_{i}<=100000 ) — the number of roses in the test. Then follow nin_{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 nin_{i} doesn't exceed 100000100000 and all coordinates are not greater than 101810^{18} by their absolute value.

输出格式

For each of tt 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 44 .

In the second sample, the maximum possible distance is 00 . Note that the positions of the roses may coincide with each other and with the position of the optimal point.

首页