QOJ.ac

QOJ

حد الوقت: 5 s حد الذاكرة: 2048 MB مجموع النقاط: 100

#5104. 画廊守护者

الإحصائيات

当地美术馆即将举办一场由世界知名艺术家创作的雕塑展览,预计将吸引成千上万的游客。不幸的是,展览也可能引来不速之客,即意图窃取艺术品的窃贼。过去,美术馆馆长们并不太担心这个问题,因为说实话,他们的永久藏品并不值得偷窃。

美术馆由多个房间组成,新展览中的每件雕塑都将放置在不同的房间里。每个房间都有一名保安和一个监控艺术品的警报器。当警报响起时,保安将从他们的岗位跑向一个可以直接看到雕塑的位置(在此过程中不能离开房间)。这是为了检查雕塑是否真的被盗,还是又一次误报。

为了确定保安的最佳驻守位置,馆长们想知道保安看到给定雕塑需要多长时间。他们希望你能提供帮助!

每个房间都在同一楼层,墙壁的布局可以近似为一个简单多边形。保安和雕塑的位置是严格位于多边形内部的不同点。雕塑是圆形的,半径小到可以忽略不计(但为正值)。为了验证雕塑是否还在,保安需要能够看到它至少一半的部分。

图 D.1 展示了两个例子。在每个例子中,保安从左侧的蓝色方块处出发,雕塑位于右侧的红色圆圈处。虚线蓝色线条显示了保安移动的最佳路径。一旦保安到达绿色菱形标记的位置,就可以看到雕塑的一半。

图 D.1:样例输入示意图。

输入格式

输入的第一行包含一个整数 $n$ ($3 \le n \le 100$),表示描述多边形的顶点数。接下来 $n$ 行,每行包含两个整数 $x$ 和 $y$ ($0 \le x, y \le 1000$),按逆时针顺序给出多边形顶点的坐标。下一行包含两个整数 $x_g$ 和 $y_g$,指定保安的位置。最后一行包含两个整数 $x_s$ 和 $y_s$,指定雕塑中心的位置。该多边形是简单的,即其顶点各不相同,且除相邻边在公共顶点处接触外,多边形的任意两条边都不相交或接触。此外,没有两条相邻的边是共线的。

输出格式

输出保安为了能看到至少一半雕塑所必须移动的最小距离。你的答案必须具有不超过 $10^{-6}$ 的绝对或相对误差。

样例

输入 1

8
0 0
20 0
20 30
60 30
60 0
80 0
80 50
0 50
10 10
70 10

输出 1

58.137767414994535

输入 2

11
0 0
4 0
4 1
5 1
5 0
7 0
7 2
3 2
3 1
2 2
0 2
1 1
6 1

输出 2

2.0

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.