QOJ.ac

QOJ

حد الوقت: 4 s حد الذاكرة: 256 MB مجموع النقاط: 100

#5570. 疫情逃生

الإحصائيات

在二维平面上的原点处有一艘宇宙飞船。平面上有 $n$ 个感染点。

在时间 $t = 0$ 时,每个感染点开始扩散,形成一个以该感染点为圆心、半径为 $t$ 的圆。同时,在时间 $t = 0$ 时,宇宙飞船也开始以速度 1 移动,并具有一定的护盾等级 $k_j$。宇宙飞船将沿直线移动,直到某一时刻,包含它的感染圆数量达到其护盾等级(此时它将被合并后的感染所吞噬)。

飞船船长希望我们考虑 $q$ 种关于如何操纵飞船的方案。在每种潜在方案中,飞船将向点 $(x'_j, y'_j)$ 的方向移动,护盾等级为 $k_j$。注意,给定的点仅用于指示方向,即使在经过 $(x'_j, y'_j)$ 后,飞船仍会继续移动。

对于每种方案,计算飞船被摧毁的时间,或者报告飞船将永远存活。

输入格式

第一行包含一个整数 $n$ ($1 \le n \le 10^5$)。 接下来的 $n$ 行,每行包含两个整数 $x_i, y_i$ ($|x_i|, |y_i| \le 10^8$)。 第 $n + 2$ 行包含一个整数 $q$ ($1 \le q \le 10^5$)。 接下来的 $q$ 行,每行包含三个整数 $x'_j, y'_j, k_j$ ($|x'_j|, |y'_j| \le 10^8, 1 \le k_j \le 5$)。

输出格式

输出包含 $q$ 行,即每种方案中飞船被摧毁的时间(如果你的答案与标准答案的绝对误差或相对误差不超过 $10^{-6}$,则会被接受)。 如果飞船将永远存活,则输出 $-1$。 $x'_j = y'_j = 0$ 的情况应视为无效测试用例。对于此类查询,输出 $-1$。

样例

输入 1

5
5 -3
5 4
-6 2
-5 0
4 1
2
-3 -10 1
6 -9 1

输出 1

8.700255424092125
3.2260195622572536

输入 2

8
4 -1
4 -8
0 9
4 -7
-5 -2
5 -5
7 5
-9 2
10
4 -8 1
7 -7 5
-10 8 2
-9 9 2
4 -7 5
-1 -10 2
6 -3 2
2 -9 3
-10 -10 1
5 9 1

输出 2

3.1677629681247024
26.162950903902267
5.461488320163311
6.363961030678928
-1
5.2894082216425735
3.726779962499649
4.6097722286464435
2.9294423792014115
4.7617289402064875

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.