Problem 3023 --Support or Not

3023: Support or Not

"
Time Limit $6$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $0$ 正确数量 $0$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
There are nn spheres in 3D-space, labeled by 1,2,…,n1,2,…,n. The ii-th sphere's center is at (xi,yi,zi)(xi,yi,zi), and the radius of it is riri

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

d(i,j)=max(0,(xi−xj)2+(yi−yj)2+(zi−zj)2−−−−−−−−−−−−−−−−−−−−−−−−−−−√−ri−rj)d(i,j)=max(0,(xi−xj)2+(yi−yj)2+(zi−zj)2−ri−rj)


That means choosing two points PP and QQ, where PP is on the ii-th sphere's surface or inside it, QQ is on the jj-th sphere's surface or inside it, and minimize the Euclidean distance bewteen PP and QQ

There are n(n−1)2n(n−1)2 pairs of i,j(1≤i<j≤n)i,j(1≤i<j≤n), please find the kk-th smallest values among these d(i,j)d(i,j).
The first line of the input contains an integer T(1≤T≤3)T(1≤T≤3), denoting the number of test cases. 

In each test case, there are two integers n,k(2≤n≤100000,1≤k≤min(300,n(n−1)2))n,k(2≤n≤100000,1≤k≤min(300,n(n−1)2))in the first line, denoting the number of spheres and the parameter kk

For the next nn lines, each line contains four integers xi,yi,zi,ri(0≤xi,yi,zi≤106,1≤ri≤106)xi,yi,zi,ri(0≤xi,yi,zi≤106,1≤ri≤106), denoting each sphere.
For each test case, print kk lines, each line contains an integer, denoting the kk-th smallest values among these d(i,j)d(i,j). You should print them in non-decreasing order. To avoid precision error, print ⌈d(i,j)⌉⌈d(i,j)⌉ instead. For example, ⌈5⌉=5⌈5⌉=5, and ⌈5.1⌉=6⌈5.1⌉=6.
1
4 6
0 0 0 1
0 3 2 2
3 2 1 1
1 1 2 2
0
0
0
1
1
2

推荐代码 查看3023 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$ $ms]
内存最少[$ $KB]
第一AC
第一挑战

赛题来源/所属竞赛 2019 Multi-University Training Contest 6 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛