QOJ.ac

QOJ

Time Limit: 4 s Memory Limit: 256 MB Total points: 100

#11140. Zaczarowany Ołówek

Statistics

今年的算法竞赛(Potyczki Algorytmiczne)组织者显然已经想不出什么好题目了,但决赛又必须准备。不过别担心!Piotrek,也就是“魔法铅笔”的主人,前来救场了。

Piotrek 将在平面上依次画出 $n$ 个三角形——也就是说,他会用他的铅笔沿着每个三角形的周长画线。这支魔法铅笔表面上画出的线条看起来很正常,但它的特性是:如果它第二次经过纸上的某一点,该点就会停止被绘制并从纸上消失,就像它从未存在过一样。当然,如果第三次经过该点,它会再次出现;第四次经过时又会消失,以此类推。

为什么要这么麻烦?正如我们所说,我们需要给你们出一道题。请计算最终图形的周长,即 Piotrek 画完所有三角形后,纸上可见的所有线段的长度之和。

输入格式

输入的第一行包含一个整数 $n$ ($1 \le n \le 100\,000$),表示三角形的数量。

接下来的 $n$ 行描述了这些三角形。第 $i$ 行包含六个整数 $x_1, y_1, x_2, y_2, x_3, y_3$,表示第 $i$ 个三角形的顶点坐标为 $(x_1, y_1), (x_2, y_2)$ 和 $(x_3, y_3)$。每个三角形都是非退化的,即其顶点不共线。所有点的坐标均在 $[-10^6, 10^6]$ 范围内。

输出格式

输出一个实数,表示纸上可见线段的总长度。如果你的答案的相对误差或绝对误差不超过 $10^{-6}$,则该答案将被接受。

注意:由于技术原因,小数点后输出超过 18 位数字可能会导致“答案错误”的判决。

样例

输入 1

2
1 1 3 1 2 3
3 3 4 1 2 1

输出 1

10.9442719100

输入 2

2
0 1 2 1 1 2
1 1 2 0 3 1

输出 2

7.6568542495

说明 1

第一个测试用例的结果为 $2 + 4\sqrt{5} \approx 10.94427190999916$,第二个测试用例的结果为 $2 + 4\sqrt{2} \approx 7.656854249492381$。两者均在下方的图片中进行了说明。

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.