QOJ.ac

QOJ

実行時間制限: 3 s メモリ制限: 512 MB 満点: 100

#3014. 把它剪掉!

統計

给定两个凸多边形 $A$ 和 $B$。保证 $B$ 严格包含在 $A$ 的内部。

你希望通过一系列切割操作从 $A$ 中切出 $B$。为此,你需要画一条完全穿过 $A$ 的直线,且该直线必须经过 $B$ 的某条边,这条直线会将 $A$ 分割成两部分。你沿着这条直线进行切割,并丢弃不包含 $B$ 的那一部分。重复此过程,直到剩下的部分恰好为 $B$。

进行一次切割的代价等于切割线的长度(即该直线穿过 $A$ 剩余部分时的长度)。给定 $A$ 和 $B$,求出切出 $B$ 所需的最小总代价。

输入格式

每个输入包含一个测试用例。注意,你的程序可能会在不同的输入上运行多次。每个测试用例的第一行包含一个整数 $a$ ($3 \le a \le 200$),表示多边形 $A$ 的顶点数。接下来的 $a$ 行,每行包含两个整数 $x$ 和 $y$ ($-10^6 \le x, y \le 10^6$),按顺时针顺序给出多边形 $A$ 的顶点。保证多边形 $A$ 是凸多边形。

下一行包含一个整数 $b$ ($3 \le b \le 200$),表示多边形 $B$ 的顶点数。接下来的 $b$ 行,每行包含两个整数 $x$ 和 $y$ ($-10^6 < x, y < 10^6$),按顺时针顺序给出多边形 $B$ 的顶点。保证多边形 $B$ 是凸多边形。同时保证多边形 $B$ 完全位于多边形 $A$ 的内部。

多边形内部或跨多边形的任意三点均不共线。

输出格式

输出一个浮点数,表示从 $A$ 中切出 $B$ 的最小代价。为了被视为正确,该数值必须与裁判答案的相对误差在 $10^{-6}$ 以内。

样例

输入 1

4
0 0
0 14
15 14
15 0
4
8 3
4 6
7 10
11 7

输出 1

40.0000000000

输入 2

4
-100 -100
-100 100
100 100
100 -100
8
-1 -2
-2 -1
-2 1
-1 2
1 2
2 1
2 -1
1 -2

输出 2

322.1421356237

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.