QOJ.ac

QOJ

時間限制: 0.4 s 記憶體限制: 1024 MB 總分: 100

#4956. 三角形的几何学

统计

每一个多边形都可以通过拼接三角形来构造。特别地,我们可以迭代地进行此操作:从一个三角形开始,添加第二个三角形,将其一条边与初始三角形的一条边重合;添加第三个三角形,将其一条边与其中一个原始三角形的空闲边重合,依此类推。我们仅考虑可以通过这种方式构造的多边形,其中每个添加的三角形都恰好与一个先前放置的三角形的一条边接触(并重合)。

给定一个多边形 $P$,令 $T$ 为用于构成它的三角形集合。每个三角形的边都是线段。令 $L$ 为构成 $T$ 中某些三角形的边的线段集合。注意,$L$ 中的每个元素都是 $T$ 中一个或两个元素的一条边。

一旦我们在平面上放置了一个多边形,在某些情况下,我们可以移除构成它的一些三角形,而不改变集合 $L$。我们希望移除一些三角形,使得集合 $L$ 保持不变,且剩余三角形的总面积最小。等价地,我们希望选择 $T$ 的一个子集 $S$,使得:

  1. $L$ 中的每个元素都是 $S$ 中至少一个三角形的边;以及
  2. $S$ 中各元素面积之和尽可能小。

输入格式

输入的第一行包含一个整数 $N$,$1 \le N \le 10^5$,对应于多边形 $P$ 三角剖分中的三角形数量。接下来的 $N$ 行,每行包含 6 个数字 $x_1, y_1, x_2, y_2, x_3$ 和 $y_3$,表示一个坐标为 $(x_1, y_1), (x_2, y_2)$ 和 $(x_3, y_3)$ 的三角形。三角形以任意顺序给出。所有坐标均为整数,绝对值不超过 $10^6$。

输出格式

输出满足问题条件下的最小可能面积,保留一位小数。

在上图中,三角剖分 $T_1 = \{a, b, c, d\}$ 和 $T_2 = \{a, b, c\}$ 分别代表第一个和第二个样例。注意 $S_1 = \{a, c, d\}$ 是第一个样例的一个有效子集。三角形 $b$ 被排除在外,但它的所有边都存在于所选的三角形中。

样例

输入 1

4
0 0 0 10 10 0
10 10 0 10 10 0
10 10 0 10 0 20
10 10 20 0 10 0

输出 1

150.0

输入 2

3
0 0 0 10 10 0
10 10 0 10 10 0
10 10 20 0 10 0

输出 2

150.0

输入 3

1
0 0 1 0 0 1

输出 3

0.5

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.