题目描述
You have a toy robot that walks straight at a constant speed $v$, and you wish for it to travel on the two-dimensional plane from $(0, 0)$ to $(X, 0)$. If the plane were empty, you could start the robot facing straight east from the origin, and it would walk there in $\frac X v$ time. Unfortunately, between the start and the destination are $n$ moving sidewalks, each moving directly north or south, which affect the robot's position while it is walking.
The direction that robot is facing is not changed by the sidewalks; the robot will face in the same orientation for the entire duration of its walk. These sidewalks are aligned with the $y$-axis and are infinitely long. You still must get the robot to go from start to finish, but you'll need to adjust the orientation of the robot at the start. Given that you choose this direction correctly, so that the robot arrives exactly at the destination, how long will it take the robot to get there?
<div class='text-center'><img src='/userfiles/images/5cddb40d-dc2a-464a-bfe1-503c3b9abb3b.png'/></div>
One final caveat: You don't want the toy robot to walk for too long. If the robot cannot reach the destination in at most twice the time it would take in the absence of all moving sidewalks $(\text{i.e.}, \frac{2X}{v})$, indicate this.
输入格式
The first line consists of three space-separated numbers $n$, $X$, and $v$ $(0 \le n \le 100;\ 1 \le X \le 1,000,000;\ 1.0 \le v \le 100.0)$. Note that $v$ is not necessarily an integer.
Each of the next $n$ lines contains three space-separated numbers $l_i$, $r_i$, and $v_i$ $(0 \le l_1 \lt r_1 \le l_2 \lt r_2 \le \cdots \le l_n \lt r_n \le X;\ −100.0 \le v_i \le 100.0)$, describing the $i$th moving sidewalk. The integer $l_i$ denotes the left edge of the sidewalk, the integer $r_i$ denotes the right edge of the sidewalk, and the decimal number $v_i$ denotes the speed of the sidewalk. A positive speed means the sidewalk moves north, while a negative speed means the sidewalk moves south.
输出格式
If the robot cannot reach the destination in at most twice the time it would take in the absence of all moving sidewalks, output `Too hard` on a single line.
Otherwise, output, on a single line, the travel time of the robot from the start to the destination, rounded and displayed to exactly three decimal places.
样例输入 #1
1 806873 66 91411 631975 -57.5
样例输出 #1
15055.988
样例输入 #2
2 422193 100 38180 307590 86.4 366035 403677 -4.7
样例输出 #2
5043.896
样例输入 #3
1 670764 22.4 113447 642610 -64.8
样例输出 #3
Too hard
来源
2017 Pacific Northwest Region Programming Contest