F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Command and Conquer: Red Alert 2

Time Limit: 12000/12000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 104    Accepted Submission(s): 58


Problem Description
Being a nostalgic boy, nocriz loves watching HBK08 and Lantian28 playing the game Command and Conquer: Red Alert 2. However, he doesn't know how to play the game himself.

In the game, you own a sniper initially located at $(-10^{100},-10^{100},-10^{100})$ in a 3D world, and there are $n$ enemy soldiers where the $i$-th soldier is located at $(x_i,y_i,z_i)$. We say the range of the sniper to be $k$, if the sniper can kill all enemies such that $\max(|x_s-x_e|,|y_s-y_e|,|z_s-z_e|) \le k$, where $(x_s,y_s,z_s)$ is the location of the sniper and $(x_e,y_e,z_e)$ is the location of the enemy.

If it is only possible to move the sniper from $(x,y,z)$ to $(x+1,y,z)$, $(x,y+1,z)$ or $(x,y,z+1)$, what is the minimum $k$ such that the sniper can kill all enemies?

The sniper is allowed to move unlimited number of steps, and is allowed to kill enemies whenever he is on an integer coordinate.
 

Input
The first line contains an integer $t ( 1 \le T \le 50000)$ - the number of test cases. Then $T$ test cases follow.

The first line of each test case contains a single integer $n ( 1\le n \le 5 \times 10^5)$ - the number of enemies.

Then $n$ lines follow, each contains three integers $x_i,y_i,z_i (-10^9 \le x_i,y_i,z_i \le 10^9)$ - the location of the $i$-th enemy.

It is guaranteed that $\sum n \le 2 \times 10^6$.
 

Output
For each test case, output a single integer representing the answer.
 

Sample Input
3 2 0 0 0 1 1 1 2 0 1 0 1 0 1 5 1 1 4 5 1 4 1 9 1 9 8 1 0 0 0
 

Sample Output
0 1 2
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 06:49:05, Gzip enabled