CF89D.Space mines
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Once upon a time in the galaxy of far, far away...
Darth Wader found out the location of a rebels' base. Now he is going to destroy the base (and the whole planet that the base is located at), using the Death Star.
When the rebels learnt that the Death Star was coming, they decided to use their new secret weapon — space mines. Let's describe a space mine's build.
Each space mine is shaped like a ball (we'll call it the mine body) of a certain radius r with the center in the point O. Several spikes protrude from the center. Each spike can be represented as a segment, connecting the center of the mine with some point P, such that
(transporting long-spiked mines is problematic), where |OP| is the length of the segment connecting O and P. It is convenient to describe the point P by a vector p such that P = O + p.
The Death Star is shaped like a ball with the radius of R (R exceeds any mine's radius). It moves at a constant speed along the v vector at the speed equal to |v|. At the moment the rebels noticed the Star of Death, it was located in the point A.
The rebels located n space mines along the Death Star's way. You may regard the mines as being idle. The Death Star does not know about the mines' existence and cannot notice them, which is why it doesn't change the direction of its movement. As soon as the Star of Death touched the mine (its body or one of the spikes), the mine bursts and destroys the Star of Death. A touching is the situation when there is a point in space which belongs both to the mine and to the Death Star. It is considered that Death Star will not be destroyed if it can move infinitely long time without touching the mines.
Help the rebels determine whether they will succeed in destroying the Death Star using space mines or not. If they will succeed, determine the moment of time when it will happen (starting from the moment the Death Star was noticed).
很久很久以前,在遥远的银河系……
达斯·维德发现了义军基地的位置。现在,他打算使用死星摧毁该基地(以及基地所在的整颗行星)。
当义军得知死星正在逼近时,他们决定启用一种新型秘密武器——太空地雷。下面描述一下太空地雷的结构:
每枚太空地雷呈球形(我们称之为“雷体”),半径为 $ r $,球心位于点 $ O $。若干根尖刺从球心向外伸出。每根尖刺可表示为一条线段,连接球心 $ O $ 与某一点 $ P $,且满足条件

(运输长尖刺地雷存在困难),其中 $ |OP| $ 表示连接 $ O $ 与 $ P $ 的线段长度。为方便起见,可用向量 $ \mathbf{p} $ 描述点 $ P $,使得 $ P = O + \mathbf{p} $。
死星呈球形,半径为 $ R ( R $ 大于任意一枚地雷的半径)。它沿向量 $ \mathbf{v} $ 方向以恒定速度运动,速率等于 $ |\mathbf{v}| $。在义军首次发现死星的时刻,其球心位于点 $ A $。
义军已在死星行进路径上布设了 $ n $ 枚太空地雷。可将这些地雷视为静止不动。死星并不知晓地雷的存在,也无法探测到它们,因此不会改变其运动方向。一旦死星与某枚地雷发生接触(即与其雷体或任一尖刺相接触),该地雷即刻爆炸,并摧毁死星。所谓“接触”,是指空间中存在至少一个点,该点同时属于地雷(包括其雷体和所有尖刺)与死星。若死星可在不触碰任何地雷的情况下无限长时间持续运动,则认为其不会被摧毁。
请帮助义军判断:他们能否利用太空地雷成功摧毁死星?若能成功,请确定事件发生的时刻(以义军首次发现死星的时刻为零时刻)。
输入格式
The first input data line contains 7 integers A__x, A__y, A__z, v__x, v__y, v__z, R. They are the Death Star's initial position, the direction of its movement, and its radius ( - 10 ≤ v__x, v__y, v__z ≤ 10, |v| > 0, 0 < R ≤ 100).
The second line contains an integer n, which is the number of mines (1 ≤ n ≤ 100). Then follow n data blocks, the i-th of them describes the i-th mine.
The first line of each block contains 5 integers O__ix, O__iy, O__iz, r__i, m__i, which are the coordinates of the mine centre, the radius of its body and the number of spikes (0 < r__i < 100, 0 ≤ m__i ≤ 10). Then follow m__i lines, describing the spikes of the i-th mine, where the j-th of them describes the i-th spike and contains 3 integers p__ijx, p__ijy, p__ijz — the coordinates of the vector where the given spike is directed (
).
The coordinates of the mines' centers and the center of the Death Star are integers, their absolute value does not exceed 10000. It is guaranteed that R > r__i for any 1 ≤ i ≤ n. For any mines i ≠ j the following inequality if fulfilled:
. Initially the Death Star and the mines do not have common points.
第一行输入数据包含 7 个整数 Ax, Ay, Az, vx, vy, vz, R,分别表示死星的初始位置、其运动方向以及其半径(其中 −10≤vx, vy, vz≤10,∣v∣>0,0<R≤100)。
第二行包含一个整数 n,表示地雷的数量(1≤n≤100)。随后是 n 个数据块,第 i 个数据块描述第 i 颗地雷。
每个数据块的第一行包含 5 个整数 Oix, Oiy, Oiz, ri, mi,分别表示该地雷中心的坐标、其本体半径以及尖刺数量(其中 0<ri<100,0≤mi≤10)。接下来有 mi 行,描述第 i 颗地雷的尖刺;其中第 j 行描述第 i 颗地雷的第 j 根尖刺,包含 3 个整数 pijx, pijy, pijz —— 表示该尖刺所指向的向量的坐标(
)。
所有地雷中心及死星中心的坐标均为整数,其绝对值均不超过 10000。保证对任意 1≤i≤n,均有 R>ri。对任意两颗不同地雷 i=j,满足如下不等式:
。初始状态下,死星与所有地雷均无公共点。
输出格式
If the rebels will succeed in stopping the Death Star using space mines, print the time from the moment the Death Star was noticed to the blast.
If the Death Star will not touch a mine, print "-1" (without quotes).
For the answer the absolute or relative error of 10 - 6 is acceptable.
如果义军能够成功利用太空水雷摧毁死星,则输出从发现死星到其爆炸所经过的时间。
如果死星不会触碰到任何水雷,则输出 “-1”(不带引号)。
答案允许的绝对或相对误差为 10−6。
输入输出样例
输入#1
0 0 0 1 0 0 5 2 10 8 0 2 2 0 -3 0 2 2 0 20 0 0 4 3 2 4 0 -4 3 0 1 -5 0
输出#1
10.0000000000
输入#2
8 8 4 4 4 2 6 1 -2 -2 -1 3 0
输出#2
-1
输入#3
30 30 2 1 2 1 20 3 0 0 40 5 1 1 4 4 -10 -40 -5 7 0 100 200 95 8 1 -10 0 0
输出#3
74.6757620881
输入解题思路,AI测评打分。不知道怎么写?