#P5554. 篮球统计

篮球统计

Description

When a basketball is thrown into the air, Xiao L records a time ll, from which this basketball starts being counted by Xiao L. When a basketball is caught, Xiao L records a time rr, after which the state of this basketball is no longer counted by Xiao L. For each basketball, Xiao L computes the height of this basketball at time ll and its initial upward velocity.

For a time xx, Xiao L wants to know: among all basketballs that are still in the air at that moment, what is the height of the highest one.

Note: The discovered basketballs' times l,rl, r and Xiao L's query times xx have no monotonicity.

Input Format

The first line contains an integer mm.

The next mm lines each describe an operation or a query, in one of the following forms:

  1. add a v l r: Xiao L discovers a basketball in the air. This basketball is thrown into the air at time ll and is caught at time rr. Its height at time ll is aa, and its initial upward velocity is vv.

  2. query x: Please tell Xiao L, based on the information he has given so far, what the maximum height is among all basketballs that are in the air at time xx.

Output Format

For each query operation, output one line containing this maximum height. If there is no basketball in the air at that time, output Undefined.

To reduce precision errors, it is recommended to use the long double type to store floating-point numbers, and use %Lf as the output format.

To avoid precision issues, this problem uses Special Judge. If the difference between your answer and the reference solution's answer is less than or equal to 0.0050.005, it will be considered correct.

5
query 1.000
add 1.000 5.000 1.000 2.000
query 1.000
query 2.000
query 1.500
Undefined
1.000000
1.100000
2.275000

Hint

For 30%30\% of the testdata, m5000m \le 5000.

For another 30%30\% of the testdata, 100<l,r,x<100-100 < l, r, x < 100.

For 100%100\% of the testdata, 1m1000001 \le m \le 100000, 1000<a,v<1000-1000 < a, v < 1000, 106<l,r,x<106-10^6 < l, r, x < 10^6, lrl \le r. It is guaranteed that all decimals in the input have exactly 33 digits after the decimal point.

The basketball's height may be negative.

Xiao K Teaches You Physics

All units in this problem use the International System of Units (SI). That is, the time unit is seconds (ss), and the length unit is meters (mm).

In this problem, the gravitational acceleration is g=9.8 ms2g = 9.8 ~ m \cdot s^{-2}.

Ignoring the horizontal displacement of the basketball, we can treat its motion as vertical upward throw motion. Based on the information given in the statement, if the basketball's initial height is aa, initial velocity is vv, gravitational acceleration is gg, and the time in the air is tt, then the height of the basketball at that time is 12gt2+vt+a-\dfrac 1 2 g t^2 + vt + a.

Translated by ChatGPT 5