Command and Conquer: Red Alert 2
Time limit10sMemory limit512 MB
Find the smallest Chebyshev range k so a sniper moving only in +x, +y, or +z steps from far away can cover all enemies in 3D.
- Level
Hard8 of 10
- Topics
- Binary search, Greedy, Sorting
- Solved
- No attempts yet
Problem
Nocriz is a nostalgic boy who loves watching HBK08 and Lantian28 play Command and Conquer: Red Alert 2. However, he does not know how to play the game himself.
In the game, you own a sniper initially located at in a 3D world. There are enemy soldiers, where the -th soldier is located at . We say the range of the sniper is if the sniper can kill all enemies such that , where is the location of the sniper and is the location of the enemy.
In one step, the sniper can move from to , , or . The enemies do not move. The sniper may make an unlimited number of steps and may kill all enemies in range whenever all of its coordinates are integers. What is the minimum range such that the sniper can eventually kill all enemies?
Input
The first line contains an integer (), the number of test cases. Then test cases follow.
The first line of each test case contains a single integer (), the number of enemies.
Then lines follow, each containing three integers , , () denoting the location of the -th enemy.
It is guaranteed that .
Output
For each test case, output a line with a single integer representing the minimum range .