QOJ.ac

QOJ

Limite de temps : 3.0 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓

#10435. 创新洗衣机

Statistiques

你需要帮助一个参加“创新工作坊”的团队,这是一个学生们发明并展示创新想法的活动。其中一个团队开发了一种新型洗衣机,显著减少了洗衣所需的能源消耗。

这个创新想法是使用一个凸多边形而不是圆形作为洗衣机滚筒的形状。给定这个多边形。滚筒绕多边形内的一个固定点旋转,转速为恒定的 1 秒 1 转。

目前,原型机已经制造完成并开始测试。滚筒内有 $s$ 升水。在每一时刻,受重力影响,水占据滚筒底部面积为 $s$ 的区域。

多边形中处于水下的顶点会受到压力。根据帕斯卡定律,我们知道压力与深度成正比。设 $d_1, d_2, \dots, d_k$ 为某一时刻处于水下的顶点的深度,$k$ 为水下顶点的数量。定义压力不平衡度为水下顶点深度与最大水下顶点深度之差的平均值,即 $\frac{1}{k} \sum_{i=1}^{k} (\max_{j=1}^{k} d_j - d_i)$。注意 $d_i$ 的顺序并不重要。

第三个测试用例中的多边形旋转后的状态。顶点 1, 2, 3, 4, 8 处于水下。

为了选择滚筒的最佳形状,团队想要知道在区间 $[0, 1]$(以秒为单位)内均匀随机选择一个时刻时,压力不平衡度的期望值。请帮助团队计算该值。

输入格式

第一行包含一个整数 $t$ ($1 \le t \le 10^4$),表示测试用例的数量。接下来是各测试用例的描述。

每个测试用例的第一行包含两个整数 $n, s$ ($3 \le n \le 2 \cdot 10^5, s \ge 1$),分别表示多边形的顶点数和滚筒内的水量。保证 $s$ 小于多边形的面积。

接下来的 $n$ 行,每行包含两个整数 $x_i, y_i$ ($|x_i|, |y_i| \le 10^8$),表示多边形顶点的坐标。

保证给定的点构成一个凸多边形。多边形的面积为正,且没有两条连续的线段共线。多边形的顶点按逆时针顺序给出。

所有测试用例的 $n$ 之和不超过 $2 \cdot 10^5$。

输出格式

对于每个测试用例,输出一个实数,表示随机均匀时刻下压力不平衡度的期望值。

如果你的答案与标准答案的绝对误差或相对误差不超过 $10^{-5}$,即如果 $p$ 是你的答案,$j$ 是标准答案,满足 $\frac{|p-j|}{\max\{1,|j|\}} \le 10^{-5}$,则你的答案将被接受。

样例

输入 1

4
4 2
0 0
2 0
2 2
0 2
3 1
1 -1
0 1
-1 -1
8 18
-2 1
-2 -3
-1 -4
0 -4
3 -3
4 -1
4 0
-1 2
4 1
99999998 99999999
99999999 99999998
100000000 99999999
99999999 100000000

输出 1

0.3729232286
0.1379212354
1.3663189952
0.2636965438

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.