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

Support or Not

Time Limit: 6000/6000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 254    Accepted Submission(s): 37


Problem Description
There are $n$ spheres in 3D-space, labeled by $1,2,\dots,n$. The $i$-th sphere's center is at $(x_i,y_i,z_i)$, and the radius of it is $r_i$.

Let's denote the distance between the $i$-th sphere and the $j$-th sphere $d(i,j)$ as

\[d(i,j)=\max(0,\sqrt{(x_i-x_j)^2+(y_i-y_j)^2+(z_i-z_j)^2}-r_i-r_j)\]

That means choosing two points $P$ and $Q$, where $P$ is on the $i$-th sphere's surface or inside it, $Q$ is on the $j$-th sphere's surface or inside it, and minimize the Euclidean distance bewteen $P$ and $Q$.

There are $\frac{n(n-1)}{2}$ pairs of $i,j(1\leq i<j\leq n)$, please find the $k$-th smallest values among these $d(i,j)$.
 

Input
The first line of the input contains an integer $T(1\leq T\leq 3)$, denoting the number of test cases.

In each test case, there are two integers $n,k(2\leq n\leq 100000,1\leq k\leq\min(300,\frac{n(n-1)}{2}))$ in the first line, denoting the number of spheres and the parameter $k$.

For the next $n$ lines, each line contains four integers $x_i,y_i,z_i,r_i(0\leq x_i,y_i,z_i\leq 10^6,1\leq r_i\leq 10^6)$, denoting each sphere.
 

Output
For each test case, print $k$ lines, each line contains an integer, denoting the $k$-th smallest values among these $d(i,j)$. You should print them in non-decreasing order. To avoid precision error, print $\lceil d(i,j)\rceil$ instead. For example, $\lceil 5\rceil=5$, and $\lceil 5.1\rceil=6$.
 

Sample Input
1 4 6 0 0 0 1 0 3 2 2 3 2 1 1 1 1 2 2
 

Sample Output
0 0 0 1 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-04-20 05:52:19, Gzip enabled