QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 1024 MB Total points: 100 Hackable ✓

#10693. 像素鸟

Statistics

你玩过《Flappy Bird》吗?《Flappy Bird》是一款 2013 年 5 月在 iPhone 上发布的游戏。玩家控制一只不断向右移动并下落的小鸟,通过点击屏幕可以让小鸟向上飞行。绿色的管道会不断出现在屏幕上阻挡小鸟的路径。具体来说,这些管道可以被看作是从屏幕顶部延伸到底部的柱子,中间有一个随机位置的缺口。

游戏的挑战当然是完美地控制小鸟穿过尽可能多的管道。然而有一天,一位名叫 Zisk 的游戏专家精通了这款游戏,并注意到管道的数量似乎只有 $N$ 个(他可能下载了一个盗版游戏)。无论他怎么做,他都无法获得更高的分数,因为他已经通过了所有的管道!

感到无聊的 Zisk 决定给自己一个新的挑战:找到从屏幕左侧起点到右侧终点的最短路径长度。

形式化地,我们可以将所有物体放置在一个由矩形 $0 \le x \le L$ 和 $0 \le y \le H$ 限制的二维平面上。起点位于 $(0, s)$,终点位于 $(L, t)$。$N$ 个管道位于 $x$ 坐标 $x_1, x_2, \dots, x_N$ 处,第 $i$ 个管道的缺口位于 $y$ 坐标范围 $[\ell_i, r_i]$ 内。将小鸟视为平面上的一个点,并假设其路径可以是任意曲线。

你能帮 Zisk 计算最短路径长度,以便他验证自己的表现吗?

输入格式

第一行包含五个整数:$N, L, H, s$ 和 $t$,其含义如题目描述所述($1 \le N \le 3 \cdot 10^5$;$1 \le L, H \le 10^9$;$0 \le s, t \le H$)。

接下来的 $N$ 行,每行包含三个整数:$x_i, \ell_i$ 和 $r_i$,描述第 $i$ 个管道($0 < x_i < L$;$0 \le \ell_i < r_i \le H$)。

所有 $x_i$ 均不相同。注意,$x_i$ 的值可能不是有序的。

输出格式

输出一个实数,表示从起点到终点的最短路径长度。

如果你的答案与标准答案的绝对误差或相对误差不超过 $10^{-6}$,则视为正确。形式化地,设你的答案为 $a$,标准答案为 $b$,如果 $\frac{|a-b|}{\max(1, |b|)} \le 10^{-6}$,则你的答案被认为是正确的。

样例

样例输入 1

3 9 11 0 11
2 2 5
5 0 2
7 3 6

样例输出 1

15.68572788688027230819

Figure 1. Illustration of the shortest path through the pipes.

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#526Editorial Open集训队作业 解题报告 by 刘墨涵Qingyu2026-01-02 21:43:32 Download

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 1
IDTypeStatusTitlePosted ByLast UpdatedActions
#717General DiscussionOpen本题重题:arc001dFlamire2026-01-15 19:57:19View

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.