题目描述
Problem Description
As is well known, the giant dragon Y is lurking not far from the country of P. Legend has it that in ancient times, the dragon Y stole the national treasure of P and hid it in its lair, attracting all adventurers from P to retrieve it, especially Captain W of the Royal Guard. With the help of P's Quantum Technology Laboratory, Captain W used quantum transmission to enter the dragon Y's treasure room and successfully retrieved the national treasure. However, the dragon's defensive barriers activated, trapping Captain W in the Medusa's Labyrinth.
Trapped at the origin point (0,0) of the labyrinth, Captain W quickly observed the structure of Medusa's Labyrinth and found that the exit is located at (p,q). The dragon Y has set up n flame breath mechanisms in the labyrinth, each described by three parameters (x,y,θ), indicating the coordinates (x,y) on the plane and the angle θ of the flame breath direction relative to the positive x-axis. The dragon's powerful force makes the flame breath infinitely long, and Captain W cannot pass through the covered rays (note that the coordinates of the mechanism, if not covered by other flame breaths, are passable). Additionally, the labyrinth has placed the Eye of Medusa infinitely far along the negative x-axis, forcing Captain W to move towards the positive x-direction (i.e., the projection of Captain W's movement direction on the positive x-axis must be positive, not negative or zero), otherwise Captain W will be instantly petrified and unable to escape.
In a hurry, Captain W needs to escape the Medusa's Labyrinth before the dragon Y catches him, so he immediately seeks help from P's advisory team. As the head of the advisory team, you are sure to help Captain W find the shortest safe path to the labyrinth exit.
Input Format
The first line contains three integers n, p, q representing the total number of flame breath mechanisms and the exit coordinates.
The next n lines, each containing two integers and a real number (x,y,θ), describe the coordinates of the mechanism and the angle of the flame breath relative to the positive x-axis.
Output Format
The output file should contain a single line with a decimal number, representing the length of the shortest path. Your answer is considered correct if the relative error with the standard answer does not exceed 10^-8 (i.e., $\frac{|a-o|}{a}\leq10^{-8}$, where a is the standard answer and o is the output).
Sample Input and Output
Input Sample #1
7 20 -5
4 3 -2.875
5 7 -1.314
10 -2 0.666
16 1 -1.571
16 1 1.571
23 -3 -2.130
14 -5 3.073
Output Sample #1
33.3380422500
Input Sample #2
7 20 0
5 2 1.155
5 2 1.987
5 2 -1.571
11 -4 1.765
11 -4 1.377
15 -4 1.765
15 -4 1.377
Output Sample #2
24.2735704188
Notes/Hints
30% of the data satisfies n ≤ 300;
60% of the data satisfies n ≤ 2000;
80% of the data satisfies n ≤ 10^5;
100% of the data satisfies: 0 ≤ n, p, |q|, |x|, |y| ≤ 10^6; θ ∈ [−π, π].
The data guarantees that at least one legal path exists, and neither the starting point nor the ending point is covered by the flame path.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分