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}|$ .
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.
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.
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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted