QOJ.ac

QOJ

Limite de temps : 3 s Limite de mémoire : 256 MB Points totaux : 100

#8292. Captain Run

Statistiques

As is well known, the Great Dragon Y lurks not far from Country P. Legend has it that in ancient times, the Great Dragon Y stole the national treasure of Country P and hid it in its lair, which has attracted all the adventurers of Country P to attempt to retrieve it, especially Captain W of the Royal Guard. With the help of Country P's quantum technology laboratory, Captain W used quantum teleportation to enter the Great Dragon Y's treasure room and successfully retrieved the national treasure. However, at this moment, the aggressive defensive barrier set up by the Great Dragon was activated, trapping Captain W in Medusa's labyrinth.

Trapped at $(0,0)$, Captain W quickly observed the structure of Medusa's labyrinth and found that the exit is located at $(p, q)$. The Great Dragon Y has placed $n$ flame breath mechanisms in the labyrinth. Each mechanism can be represented by three parameters $(x, y, \theta)$, which specify the coordinates $(x, y)$ of the mechanism in the plane and the inclination angle $\theta$ of the flame breath relative to the positive $x$-axis. The Great Dragon's powerful force makes the flame breath infinitely long, and Captain W cannot pass through the rays covered by the flame breath (note that if the coordinate where a mechanism is located is not covered by any other flame breath, it is passable). At the same time, the labyrinth has placed the Eye of Medusa at infinity in the negative $y$-axis direction, which forces Captain W to tend to move in the positive $y$-axis direction (i.e., the projection of Captain W's movement direction onto the positive $y$-axis must be positive; it cannot be negative or zero), otherwise, Captain W will be instantly petrified and unable to escape.

Anxious, Captain W needs to escape Medusa's labyrinth before the Great Dragon Y catches him, so he immediately asks the Country P think tank for help. As the head of the think tank, you must be able to help Captain W find the shortest path to safely reach the labyrinth exit.

Input

The input file is named captain.in.

The first line contains three integers $n, p, q$, representing the total number of flame breath mechanisms and the coordinates of the exit.

The next $n$ lines each contain two integers and one real number $x, y, \theta$, representing the coordinates of the mechanism and the inclination angle of the flame breath relative to the positive $x$-axis.

Output

The output file is named captain.out.

The output file contains only one decimal number, representing the length of the shortest path. Your answer is considered correct if the relative error between your answer and the standard answer does not exceed $10^{-8}$ (i.e., $|a-o|/a \le 10^{-8}$, where $a$ is the standard answer and $o$ is your output).

Constraints

$30\%$ of the data satisfies $n \le 300$; $60\%$ of the data satisfies $n \le 2000$; $80\%$ of the data satisfies $n \le 10^5$; $100\%$ of the data satisfies: $0 \le n, |p|, |q|, |x|, |y| \le 10^6$; $\theta \in [-\pi, \pi)$.

The data guarantees that at least one valid path exists, and neither the starting point nor the ending point is covered by any flame path.

Examples

Input 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 1

33.3380422500

Input 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 2

24.2735704188

Figure 1. Illustration of the shortest path in Medusa's labyrinth for Example 1.

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 0
No discussions in this category.

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.