QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 1024 MB Total points: 100

#6118. 心之大地

Statistics

Eartheart Kingdom 是一个位于地下的昏暗国度。阳光通常无法照射到 Eartheart Kingdom,但每隔几年就会有一天阳光能够照入:星期天。在那一天,太阳会直接经过 JAG Kingdom “天花板”上的一个洞,从而透出光亮。Eartheart Kingdom 的男孩 Bob 想知道,在下一个星期天,他能通过这个洞看到完整太阳的总时长是多少。请帮帮他。

Eartheart Kingdom 的天花板由一个二维平面表示。太阳由一个半径为 $R$ 的圆表示,其圆心以每单位时间 $1$ 的速度从 $(-10^{100}, 0)$ 直线移动到 $(10^{100}, 0)$。洞由二维平面上的一个简单多边形表示。你的任务是求出圆被完全包含在多边形内的总时长。当且仅当圆内部或圆周上的任意点都在多边形内部或边界上时,称该圆被包含在多边形内。

输入格式

第一行包含两个整数 $N$ 和 $R$ ($3 \le N \le 10^5$, $1 \le R \le 10^6$),用空格分隔,分别表示多边形的顶点数和圆的半径。接下来的 $N$ 行,每行包含两个整数 $x_i$ 和 $y_i$ ($-10^6 \le x_i, y_i \le 10^6$),用空格分隔,表示多边形的第 $i$ 个顶点。保证多边形是简单的。换句话说,多边形的任意两条边互不相交。

输出格式

输出圆被包含在多边形内的总时长。如果输出值的绝对误差或相对误差小于 $10^{-5}$,则视为正确。

样例

样例输入 1

4 5
-5 -5
5 -5
5 5
-5 5

样例输出 1

0.0000000000

样例输入 2

4 5
-10 -10
10 -10
10 10
-10 10

样例输出 2

10.000000000

样例输入 3

9 10
-100 -80
-90 130
-30 150
0 160
100 130
120 90
110 -60
80 -100
0 -120

样例输出 3

190.1569477022

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.