QOJ.ac

QOJ

Límite de tiempo: 6.0 s Límite de memoria: 1024 MB Puntuación total: 100 Hackeable ✓

#10224. 岛屿入侵

Estadísticas

Big Island 和 Tiny Island 是小海中的两个相邻岛屿。Big Island 的国王想要征服 Tiny Island 以满足他脆弱的自尊心。然而,小海中风力强劲,且船只又慢又轻。因此,到达 Tiny Island 可能既困难又耗时;在某些情况下,甚至是不可能的。此外,天气多变,风向难以预测。因此,国王希望提前制定计划,并根据给定的各种风速,找出从 Big Island 到达 Tiny Island 所需的最短时间。

Big Island 和 Tiny Island 可以分别描述为两个互不相交的凸多边形,分别有 $n$ 个和 $m$ 个顶点。国王会向你提出 $q$ 次询问。在每次询问中,你将获得一个表示风速的向量 $\vec{w} = (w_x, w_y)$ 和一个整数 $s$,即 Big Island 船只的最大航速。船只可以选择从 Big Island 的任意一点出发,并选择它们喜欢的任何方向移动。如果船只自身的航速由 $\vec{v}$ 描述,则 $|\vec{v}|$ 不得超过 $s$,且船只的合成速度将为 $\vec{v} + \vec{w}$。

你的任务是针对每次询问,确定是否可以到达 Tiny Island 的任意一点。如果可以,你还需要找出所需的最短时间。

输入格式

第一行包含测试用例的数量 $T(1 \le T \le 1111)$。

每个测试用例的第一行包含两个整数 $n$ 和 $m(3 \le n, m \le 10^5)$。接下来的 $n$ 行,每行包含两个整数 $x$ 和 $y(-10^9 \le x, y \le 10^9)$,表示 Big Island 的一个顶点坐标。接下来的 $m$ 行,每行包含两个整数 $x$ 和 $y(-10^9 \le x, y \le 10^9)$,表示 Tiny Island 的一个顶点坐标。对于每个多边形,顶点均按逆时针顺序给出。

下一行包含一个整数 $q(1 \le q \le 2 \cdot 10^4)$。接下来的 $q$ 行,每行包含三个整数 $w_x, w_y(-10^9 \le w_x, w_y \le 10^9)$ 和 $s(0 \le s \le 10^9)$。

保证所有测试用例中 $n + m$ 的总和不超过 $2 \cdot 10^5$,且 $q$ 的总和不超过 $2 \cdot 10^4$。

输入数据的生成方式保证了当可以到达 Tiny Island 时,任何询问的答案最多为 $10^9$。

输出格式

对于每次询问,输出一行。

  • 如果无法到达 Tiny Island 的任何一点,输出 -1。
  • 否则,输出一个实数,表示到达 Tiny Island 的任何一点所需的最短时间。

如果你的答案的绝对误差或相对误差不超过 $10^{-6}$,则被视为正确。即,如果你的答案是 $a$,裁判的答案是 $b$,则当 $\frac{|a-b|}{\max(1, |b|)} < 10^{-6}$ 时,你的答案被视为正确。

样例

样例输入 1

1
4 4
0 0
1 0
1 1
0 1
2 2
3 2
3 3
2 3
2
1 1 1
-1 -1 1

样例输出 1

0.5857860308
-1

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.