P28778 [洛谷] [CTSC2009] Magical Garden
入门
题目描述

Problem Description

Magician Dongdong has a beautiful magical garden. In the garden, Dongdong grows various magical plants, and the garden is always filled with vibrant flowers throughout the year. Dongdong's friends especially enjoy visiting the garden.

The irrigation system in the garden is specially designed by Dongdong. He uses magic to create $n$ sprinklers above the garden, all connected to the nearby Holy Water River. During irrigation, all sprinklers spray water simultaneously, creating beautiful arcs in the air, which precisely irrigate the $n$ most water-deprived magical plants.

Sprinklers

Dongdong places each sprinkler at the same height $h$. All sprinklers are horizontally positioned, and when water is sprayed from the sprinklers, it only has horizontal velocity (which may vary among sprinklers). The magical garden has no wind, and air resistance can be ignored. Therefore, under the influence of gravity (with gravitational acceleration $g$ in the magical garden), the trajectory of the water is a perfect parabola. Any point in space is at most sprayed by three sprinklers, and the intersection of two water streams does not affect their respective trajectories.

In recent years, many factories have been built near the magical garden, polluting the Holy Water River. Dongdong does not want the polluted water to affect his garden, so he uses magic to purify the irrigation water. Dongdong's magic can only purify water sprayed from the sprinklers. He can cast a spell to form a convex polygonal filter layer in the air, and all water passing through this layer will be purified. The energy required for this spell is proportional to the area of the filter layer, with each square meter requiring 1 unit of magical energy. Dongdong wants to purify all the water; how much energy does he need at a minimum?

To better describe the problem, Dongdong has established a three-dimensional Cartesian coordinate system in the garden, with the northwest corner of the garden as the origin of the coordinate axes. The positive direction of the $x$-axis is from the origin to the east, the positive direction of the $y$-axis is to the south, and the positive direction of the $z$-axis is upward. Thus, the position of the $i$-th sprinkler can be represented as $(x_i, y_i, h)$, and the position of the $j$-th magical plant can be represented as $(x_j', y_j', 0)$.

Input Format

The input file garden.in consists of:
- The first line contains two real numbers $h, g$, representing the height of the sprinklers and the gravitational acceleration of the magical garden.
- The second line contains an integer $n$, representing the number of sprinklers.
- The next $n$ lines, each containing four integers $x_i, y_i, x_i', y_i'$, separated by a space. These represent the coordinates of the $i$-th sprinkler $(x_i, y_i, h)$ and the coordinates of the magical plant it irrigates $(x_i', y_i', 0)$.

Output Format

The output file garden.out contains a single real number, representing the minimum energy Dongdong needs, accurate to at least three decimal places.

Sample Input and Output

Sample Input #1

36 2 
3 
99 100 105 100 
101 100 95 100 
100 99 100 105

Sample Output #1

0.000

Sample Input #2

10 9.8 
3 
0 0 0 0 
1 0 100 0 
0 50 0 1

Sample Output #2

25.0000

Notes

[Sample Explanation 1]

Casting the spell at a height of $35$, all water streams converge precisely at the point $(100, 100, 35)$, so the required energy is $0$.

[Sample Explanation 2]

Casting the spell at a height of $10$ (at the sprinklers), the spell forms a right-angled triangle with coordinates: $(0,0,10), (1,0,10), (0,50,10)$, with an area of $25.000$, so the required magical energy is also $25.000$.

[Scoring Criteria]

For each test case, if your answer is within $0.001$ of the standard answer, you receive full points; if the difference is between $0.001$ and $0.002$, you receive 50% of the points; otherwise, you receive 0 points.

[Data Size]

  • For 20% of the data, $1 \leq n \leq 10$
  • For 50% of the data, $1 \leq n \leq 50$
  • For 100% of the data, $1 \leq n \leq 100$
  • $0 < h \leq 10000.0$
  • $0 < g \leq 100.0$
  • $0 \leq x_i, y_i, x_i', y_i' \leq 1000$

[Hint]

The process of water being sprayed from the sprinklers to the ground can be considered as a projectile motion. Projectile motion can be decomposed into two components: horizontal and vertical.

Let $L = (x_i - x_i')^2 + (y_i - y_i')^2$, then:

  • Initial velocity $v_0 = \sqrt{\frac{Lg}{2h}}$
  • Horizontal velocity at time $t$: $v_{\text{horizontal}}(t) = v_0$
  • Vertical velocity at time $t$: $v_{\text{vertical}}(t) =$
  • Velocity at time $t$: $v(t) = \sqrt{v_{\text{horizontal}}^2(t) + v_{\text{vertical}}^2(t)}$
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
36 2 3 99 100 105 100 101 100 95 100 100 99 100 105
样例输出
0.000