QOJ.ac

QOJ

时间限制: 1 s 内存限制: 512 MB 总分: 100

#3442. 森林公路

统计

斯洛伐克政府正在修建一条从布拉迪斯拉发到科希策的高速公路。这条公路将穿过一片有许多动物居住的森林。动物女王青蛙 Gizela 想要计算这条公路对它们生活的影响。由于公路会有噪音,动物们不想住在距离公路距离 $d$ 以内的范围内。Gizela 想知道森林中可居住区域的面积有多大。如果森林的总可居住面积太小,Gizela 就必须为她的王国寻找一片新的森林。

任务

给定森林和公路的描述。森林是一个简单多边形,即其边不相交,公路可以被视为一条宽度为零的直线。同时给定 $d$,即距离公路的安全距离。计算森林中可居住区域的面积。

图 G.1:样例输入的示意图

输入格式

输入的第一行包含一个整数 $N$ ($3 \le N \le 250\,000$),表示多边形的顶点数。接下来的 $N$ 行每行包含两个浮点数 $x_i$ 和 $y_i$,表示多边形的第 $i$ 个点为 $(x_i, y_i)$。

下一行包含 4 个浮点数 $x_a, y_a, x_b, y_b$,表示公路经过点 $(x_a, y_a)$ 和 $(x_b, y_b)$。输入的最后一行包含一个正浮点数 $d$,即距离公路的安全距离。

所有浮点数的绝对值最大为 $100\,000$,且小数点后最多有 4 位数字。

输出格式

输出一行,包含一个数字,即森林中可居住区域的面积。相对误差或绝对误差在 $10^{-7}$ 以内的结果将被视为正确。

样例

输入 1

7
0.0 0.0
2.0 4.0
4.0 0.0
5.0 5.0
1.0 6.0
1.0 4.0
-1.0 3.0
-2.0 4.0 6.0 1.0
0.6

输出 1

13.082798910

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.