QOJ.ac

QOJ

Time Limit: 3 s Memory Limit: 1024 MB Total points: 100 Hackable ✓

#6599. 盛大锦标赛

Statistics

今天,第一届自动驾驶大奖赛正式开赛了!

本次比赛的实验场地是一个二维平面上的矩形区域,其边平行于坐标轴。该矩形的左下角坐标为 $(x_l, y_l)$,右上角坐标为 $(x_r, y_r)$。矩形内部严格包含两条线段 $A$ 和 $B$。这两条线段可能有公共点。矩形内还有一辆车,可以看作一个点。

比赛的一个子任务要求车在运动过程中,其到两条线段的距离必须始终相等。点 $P$ 到线段 $Q$ 的距离定义为 $P$ 到 $Q$ 上任意一点的最小欧几里得距离。

图 1:样例数据解释。

请编写一个程序,计算车的所有有效位置构成的区域面积。

输入格式

输入包含多组测试数据。输入的第一行包含一个整数 $T$ ($1 \le T \le 10^5$),表示测试数据的组数。

对于每组测试数据,第一行包含四个整数 $x_l, y_l, x_r, y_r$ ($-1\,000 \le x_l < x_r \le 1\,000$, $-1\,000 \le y_l < y_r \le 1\,000$),表示矩形的左下角和右上角坐标。接下来的两行,每行包含四个整数 $x_1, y_1, x_2, y_2$,表示一条连接 $(x_1, y_1)$ 和 $(x_2, y_2)$ 的线段,其中 $x_1, x_2 \in (x_l, x_r)$ 且 $y_1, y_2 \in (y_l, y_r)$。

对于每组测试数据,保证每条线段的两个端点不重合。

输出格式

对于每组测试数据,输出一行,包含一个实数,表示车的所有有效位置构成的区域面积。如果你的答案与标准答案的绝对误差或相对误差不超过 $10^{-9}$,则视为正确。

形式化地,如果你的答案为 $a$,标准答案为 $b$,则当且仅当 $\frac{|a-b|}{\max\{1, |b|\}} \le 10^{-9}$ 时,你的答案被视为正确。

样例

样例输入 1

2
0 0 3 3
1 1 1 2
2 1 2 2
0 0 3 3
1 1 1 2
1 2 2 2

样例输出 1

0.000000000000000
1.000000000000000

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.