QOJ.ac

QOJ

Límite de tiempo: 1.0 s Límite de memoria: 256 MB Puntuación total: 100

#15644. 多米诺骨牌

Estadísticas

皮克斯(Pixar)正准备在 2023 年戛纳电影节上推介其下一部动画电影《疯狂元素城》(Elemental)。但其中一个场景需要重新渲染。在这个场景中,有 $n$ 个多米诺骨牌排成一条直线,其中一个骨牌应该倒下,并以多米诺骨牌效应的方式推倒后续的若干个骨牌。考虑到距离 2023 年戛纳电影节只有不到 1 个月的时间,皮克斯请求你编写一个程序,计算对于 $n$ 种初始骨牌选择,重新渲染该场景的成本。

为了简化计算,我们假设多米诺骨牌从侧面看就像坐标轴上没有宽度的线段,并且它们向左倒下。它们从左到右依次编号,第 $i$ 个多米诺骨牌的高度为 $l_i$,位于 $x_i$。重新渲染该场景的成本等于场景中运动部分的面积,即所有倒下的多米诺骨牌所扫过的四分之一圆的并集面积。请注意,多米诺骨牌倒下的区域可能会重叠,重叠的区域只能计算一次。下图展示了在第一个样例测试中,当选择第 5 个多米诺骨牌作为初始倒下骨牌时,多米诺骨牌倒下的情况。

输入格式

输入的第一行包含一个正整数 $n$,表示多米诺骨牌的数量。

接下来的 $n$ 行,每行包含一对整数 $x_i$ 和 $l_i$,表示第 $i$ 个多米诺骨牌的位置和高度。

保证 $n \le 200\,000$ 且 $1 \le x_i, l_i \le 10^9$。多米诺骨牌按从左到右的顺序给出,即 $x_i < x_{i+1}$。

输出格式

输出 $n$ 行,其中第 $i$ 行包含以第 $i$ 个多米诺骨牌作为初始倒下骨牌时,重新渲染场景的成本。所有数值的绝对误差或相对误差不能超过 $10^{-6}$。

样例

输入样例 1

7
2 2
5 3
9 5
12 1
13 5
14 2
16 3

输出样例 1

3.141592654
7.068583471
24.659773696
0.785398163
42.250963921
44.164186876
49.714124052

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.