QOJ.ac

QOJ

시간 제한: 2.0 s 메모리 제한: 1024 MB 총점: 100 해킹 가능 ✓

#17406. 蚂蚁与木棍

통계

在一个无限大的桌面上,给你两个不同的点 $A = (A_x, A_y)$ 和 $B = (B_x, B_y)$。

你还有 $M$ 根木棍,每根木棍都是长度为 $W$ 的线段。你可以将这些木棍放置在桌面上的任何位置,具有任意的位置和方向。木棍可以重叠。然而,任何木棍都不能包含点 $A$ 或点 $B$。

一只蚂蚁从 $A$ 出发,想要到达 $B$。它可以在桌面上的任何地方行走,但不能跨越任何木棍。

你想放置这些木棍,使得蚂蚁从 $A$ 到 $B$ 的最短路径长度尽可能大。

如果可以完全阻断蚂蚁,使得不存在从 $A$ 到 $B$ 的路径,则答案为 $-1$。

否则,令 $L$ 为在所有合法的木棍放置方案中,从 $A$ 到 $B$ 的最短路径长度的上确界(supremum)$^\dagger$。如果存在某种放置方案可以达到该值,则 $L$ 就是最大值。如果没有任何单一的放置方案能达到该值,但可以无限逼近,你仍须输出 $L$。

$^\dagger$ 实数集合的上确界(最小上界)是大于或等于该集合中每个值的最小实数。它可能被集合中的某个值达到,也可能达不到。

输入格式

输入格式如下:

T
A_x A_y B_x B_y M W
...
  • 所有输入值均为整数。
  • $1 \le T \le 10^4$
  • $0 \le A_x, A_y, B_x, B_y \le 10^9$
  • $1 \le M, W \le 10^9$
  • 保证 $(A_x, A_y) \ne (B_x, B_y)$。

输出格式

对于每个测试用例:

  • 如果可以完全阻断蚂蚁,输出 $-1$;
  • 否则,输出一个实数——即上述定义的 $L$ 值。

设 $X$ 为正确答案, $Y$ 为你的输出。当且仅当 $|Y - X| \le 10^{-6} \cdot \max(1, |X|)$ 时,你的输出被判定为正确。

样例

输入样例 1

2
0 0 1 1 343 434
4 5 786331192 707731892 1 639711202

输出样例 1

-1
1425074478.231629371643066

说明

测试用例 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.