Universal Cup Judging System

Universal Cup

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

在三维笛卡尔坐标系中,考虑两个不透明平面 $z = z_1$ 和 $z = z_2$ ($z_1 < z_2$)。每个平面上都有一个凸多边形孔,分别记为 $P_1$ 和 $P_2$,光线可以通过这些孔。

有一个点光源 $L$ 在平面 $z = z_0$ ($z_2 < z_0$) 上运动,运动方向平行于 $xOy$ 平面。光源在 $t = 0$ 时位于初始位置 $(x_0, y_0, z_0)$,并以恒定速度 $\boldsymbol{v} = (v_x, v_y, 0)$ 运动。因此,在任意时刻 $t$,光源的位置由 $(x_0 + v_x t, y_0 + v_y t, z_0)$ 给出。

对于平面 $z = 0$ 上的点 $A$,定义其在时刻 $t$ 被照亮,当且仅当线段 $LA$ 同时穿过两个多边形 $P_1$ 和 $P_2$ 的内部(包括边界)。在时刻 $t$,被照亮区域记为 $f(t)$,它是平面 $z = 0$ 上所有被照亮点形成的区域面积。

定义时间段 $[t_1, t_2]$ 内的平均照亮面积,记为 $\mathbb{E}[f(t)|t \sim U(t_1, t_2)]$,即假设 $t$ 是区间 $[t_1, t_2]$ 上均匀分布的随机变量时,$f(t)$ 的期望值。

给定多个时间段 $[t_1, t_2]$,你的任务是求出每个时间段的平均照亮面积。

输入格式

第一行包含一个整数 $T$ ($1 \le T \le 10^4$),表示测试用例的数量。

对于每个测试用例,第一行包含五个整数 $x_0, y_0, z_0, v_x, v_y$ ($-10^5 \le x_0, y_0 \le 10^5, 1 \le z_0 \le 10^5, -10^3 \le v_x, v_y \le 10^3$),表示光源的初始位置 $(x_0, y_0, z_0)$ 和速度向量 $\boldsymbol{v} = (v_x, v_y, 0)$。保证 $\boldsymbol{v} \neq (0, 0, 0)$。

第二行包含两个整数 $n_1$ 和 $z_1$ ($3 \le n_1 \le 10^5, 1 \le z_1 \le 10^5$),表示多边形 $P_1$ 的顶点数和 $z_1$ 的值。接下来的 $n_1$ 行,每行包含两个整数 $x_i$ 和 $y_i$ ($-10^5 \le x_i, y_i \le 10^5$),按逆时针顺序描述 $P_1$ 的顶点。

下一行包含两个整数 $n_2$ 和 $z_2$ ($3 \le n_2 \le 10^5, 1 \le z_2 \le 10^5$),表示多边形 $P_2$ 的顶点数和 $z_2$ 的值。接下来的 $n_2$ 行,每行包含两个整数 $x_j$ 和 $y_j$ ($-10^5 \le x_j, y_j \le 10^5$),按逆时针顺序描述 $P_2$ 的顶点。

保证 $P_1$ 和 $P_2$ 中没有三个或更多顶点共线。

下一行包含一个整数 $q$ ($1 \le q \le 10^5$),表示查询次数。接下来的 $q$ 行,每行包含两个整数 $t_1$ 和 $t_2$ ($0 \le t_1 \le t_2 \le 10^3$),表示一个时间段。

保证所有测试用例中 $n_1+n_2$ 的总和不超过 $10^5$,$q$ 的总和不超过 $10^5$,且 $z_1 < z_2 < z_0$。

输出格式

对于每个查询,输出一个实数,表示平均照亮面积。如果你的答案与正确答案之间的相对误差或绝对误差不超过 $10^{-4}$,则视为正确。

样例

输入格式 1

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

输出格式 1

0.450000000
1.125000000
2.250000000

说明

对于该样例,凸多边形 $P_1$ 和 $P_2$ 在 $t = 0$ 时投影到 $xOy$ 平面上的情况以及这些投影的运动如下图所示。多边形 $A_1B_1C_1D_1$ 是多边形 $P_1$ 的投影,多边形 $A_2B_2C_2D_2$ 是多边形 $P_2$ 的投影。

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.