CF1167G.Low Budget Inception

NOI/NOI+/CTSC

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

So we got bored and decided to take our own guess at how would "Inception" production go if the budget for the film had been terribly low.

The first scene we remembered was the one that features the whole city bending onto itself:

It feels like it will require high CGI expenses, doesn't it? Luckily, we came up with a similar-looking scene which was a tiny bit cheaper to make.

Firstly, forget about 3D, that's hard and expensive! The city is now represented as a number line (infinite to make it easier, of course).

Secondly, the city doesn't have to look natural at all. There are nn buildings on the line. Each building is a square 1×11 \times 1. Buildings are numbered from 11 to nn in ascending order of their positions. Lower corners of building ii are at integer points aia_i and ai+1a_i + 1 of the number line. Also the distance between any two neighbouring buildings ii and i+1i + 1 doesn't exceed dd (really, this condition is here just to make the city look not that sparse). Distance between some neighbouring buildings ii and i+1i + 1 is calculated from the lower right corner of building ii to the lower left corner of building i+1i + 1.

Finally, curvature of the bend is also really hard to simulate! Let the bend at some integer coordinate xx be performed with the following algorithm. Take the ray from xx to +∞+\infty and all the buildings which are on this ray and start turning the ray and the buildings counter-clockwise around point xx. At some angle some building will touch either another building or a part of the line. You have to stop bending there (implementing buildings crushing is also not worth its money).

Let's call the angle between two rays in the final state the terminal angle αx\alpha_x.

The only thing left is to decide what integer point xx is the best to start bending around. Fortunately, we've already chosen mm candidates to perform the bending.

So, can you please help us to calculate terminal angle αx\alpha_x for each bend xx from our list of candidates?

于是我们感到无聊,便决定自行猜测:如果电影《盗梦空间》的制作预算极低,其拍摄过程会是怎样的?

我们首先想到的场景,便是整座城市向自身弯曲的那一幕:

这看起来需要高昂的 CGI 制作费用,对吧?幸运的是,我们构思出了一个视觉效果相似、但成本略低的替代方案。

首先,彻底抛弃 3D 效果——那太难也太贵了!现在,整座城市被建模为一条数轴(为简化问题,该数轴无限延伸)。

其次,城市外观完全不必追求自然。数轴上共分布着 nn 座建筑。每座建筑均为边长为 11 的正方形(即 1×11 \times 1)。建筑按其位置从左至右依次编号为 11 至 nn。第 ii 座建筑的底边两个端点(即下角)位于数轴上的整数坐标 aia_i 和 ai+1a_i + 1 处。此外,任意两座相邻建筑 ii 与 i+1i+1 之间的距离不超过 dd(实际上,该约束仅是为了避免城市显得过于稀疏)。相邻建筑 ii 与 i+1i+1 之间的距离定义为:从建筑 ii 的右下角到建筑 i+1i+1 的左下角的水平距离。

最后,模拟弯曲曲率本身也非常困难!现定义在某个整数坐标 xx 处发生的弯曲操作如下:取从 xx 出发指向 +∞+\infty 方向的射线,以及该射线上所有的建筑;然后以点 xx 为旋转中心,将该射线及所有其上的建筑逆时针旋转。当旋转至某一角度时,某座建筑将恰好接触到另一座建筑,或接触到数轴本身。此时必须立即停止弯曲(实现建筑挤压破碎的效果同样不划算)。

我们将最终状态中两条射线之间的夹角称为终止角 αx\alpha_x。

唯一尚未确定的是:究竟选择哪个整数点 xx 作为弯曲中心最为合适。幸运的是,我们已预先选定了 mm 个候选点用于执行弯曲操作。

那么,能否请您帮我们计算出:对候选列表中的每一个弯曲中心 xx,其所对应的终止角 αx\alpha_x 是多少?

输入格式

The first line contains two integer numbers nn and dd (1≤n≤2⋅1051 \le n \le 2 \cdot 10^5, 0≤d≤70000 \le d \le 7000) — the number of buildings and the maximum distance between any pair of neighbouring buildings, respectively.

The second line contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n (a1=0a_1 = 0, 0<ai+1−ai≤d+10 \lt a_{i + 1} - a_i \le d + 1) — coordinates of left corners of corresponding buildings in ascending order.

The third line contains single integer mm (1≤m≤2⋅1051 \le m \le 2 \cdot 10^5) — the number of candidates.

The fourth line contains mm integers x1,x2,…,xmx_1, x_2, \dots, x_m (0≤xi≤an+10 \le x_i \le a_n + 1, xi<xi+1x_i \lt x_{i + 1}) — the coordinates of bends you need to calculate terminal angles for in ascending order.

第一行包含两个整数 nn 和 dd(1≤n≤2⋅1051 \le n \le 2 \cdot 10^5,0≤d≤70000 \le d \le 7000)—— 分别表示建筑物的数量以及任意相邻两座建筑物之间的最大距离。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \dots, a_n(满足 a1=0a_1 = 0,且 0<ai+1−ai≤d+10 \lt a_{i + 1} - a_i \le d + 1)—— 表示对应建筑物左端点的坐标,按升序排列。

第三行包含一个整数 mm(1≤m≤2⋅1051 \le m \le 2 \cdot 10^5)—— 表示候选点的数量。

第四行包含 mm 个整数 x1,x2,…,xmx_1, x_2, \dots, x_m(满足 0≤xi≤an+10 \le x_i \le a_n + 1,且 xi<xi+1x_i \lt x_{i + 1})—— 表示需要计算终端角度的弯折点坐标,按升序排列。

输出格式

Print mm numbers. For each bend xix_i print terminal angle αxi\alpha_{x_i} (in radians).

Your answer is considered correct if its absolute error does not exceed 10−910^{-9}.

Formally, let your answer be aa, and the jury's answer be bb. Your answer is accepted if and only if ∣a−b∣≤10−9|a - b| \le 10^{-9}.

输出 mm 个数。对于每个弯道 xix_i,输出终端角度 αxi\alpha_{x_i}(单位:弧度)。

若你的答案的绝对误差不超过 10−910^{-9},则视为正确。

形式化地,设你的答案为 aa,评测机的答案为 bb。当且仅当 ∣a−b∣≤10−9|a - b| \le 10^{-9} 时,你的答案被接受。

输入输出样例

  • 输入#1

    3 5
    0 5 7
    9
    0 1 2 3 4 5 6 7 8

    输出#1

    1.570796326794897
    1.570796326794897
    0.785398163397448
    0.927295218001612
    0.785398163397448
    1.570796326794897
    1.570796326794897
    1.570796326794897
    1.570796326794897
  • 输入#2

    2 7
    0 4
    3
    1 3 4

    输出#2

    1.570796326794897
    0.927295218001612
    1.570796326794897
  • 输入#3

    5 0
    0 1 2 3 4
    6
    0 1 2 3 4 5

    输出#3

    1.570796326794897
    3.141592653589793
    3.141592653589793
    3.141592653589793
    3.141592653589793
    1.570796326794897

说明/提示

Here you can see the picture of the city for the first example and the bend at position 22 for it. The angle you need to measure is marked blue. You can see that it's equal to π4\frac \pi 4.

You can see that no pair of neighbouring buildings have distance more than 44 between them. d=4d = 4 would also suffice for that test.

此处展示了第一个样例的城市示意图,以及该图中位置 22 处的弯折。您需要测量的角度以蓝色标出。可以看出,该角度等于 π4\frac \pi 4。

可以看出,任意相邻两栋建筑之间的距离均不超过 44。取 d=4d = 4 也足以满足该测试用例的要求。

输入解题思路,AI测评打分。不知道怎么写?

首页