#P11264. Robber and the Fixed‐Direction Police

    ID: 13337 Type: Default 1000ms 256MiB

Robber and the Fixed‐Direction Police

Robber and the Fixed‐Direction Police

Consider a two‑dimensional Cartesian coordinate system. Initially the robber is located at the origin, while there are ( n ) police officers located at distinct points (different from the origin) in the plane. All of them have the same speed ( v ) (a positive real number) and each moves along a fixed direction with uniform motion. The ( i)-th police officer’s motion is along the direction given by the angle ( \alpha_i ) (in radians). The robber may choose any direction to run (with speed ( v )); however, the police do not change their directions and will adopt the best possible strategy to catch him. When at some time the position of any police officer coincides with that of the robber, he is caught.

Formally, if the robber chooses the unit direction ( d = (\cos\varphi,\sin\varphi) ) then his position at time ( t ) is ( R(t)=v,t,d ). The ( i)-th police officer starts at ( P_i(0)=(x_i,y_i) ) and moves with velocity ( v(\cos\alpha_i, \sin\alpha_i) ), so that ( P_i(t)=(x_i,y_i)+v,t,(\cos\alpha_i, \sin\alpha_i) ). The robber is caught by the ( i)-th officer if there exist ( t\ge0 ) and a real number ( s\ge0 ) satisfying

[ v,s,(\cos\varphi,\sin\varphi)= (x_i,y_i)+v,t,(\cos\alpha_i, \sin\alpha_i). ]

It can be shown (via a simple algebraic argument) that for police ( i ) the necessary and sufficient condition for intercepting the robber is that the two rays defined by

[ L_R: { v,s,(\cos\varphi,\sin\varphi), :, s\ge0}\quad\text{and}\quad L_i: { (x_i,y_i)+v,t,(\cos\alpha_i, \sin\alpha_i), :, t\ge0}\n]

intersect (i.e. there exist ( s,t\ge0 ) such that ( L_R\cap L_i\neq \emptyset )). In particular, if for a chosen ( \varphi ) none of the police’s trajectories meets the robber’s trajectory then the robber escapes. Otherwise the robber is inevitably caught – and being clever he will choose the escape direction ( \varphi ) that maximizes the Euclidean distance from the origin where he gets caught.

Your task is to determine whether there exists a direction ( \varphi ) in which the robber can escape. If so, output a line containing only the string YES. Otherwise, output NO on the first line and, on the second line, the maximum possible distance from the origin at which the robber is caught (when he chooses the optimal direction). (Answers within ( 10^{-6} ) absolute or relative error are accepted.)

Note: All input coordinates and angles (( \alpha_i )) are real numbers. All ( n+1 ) starting positions are pairwise distinct.

inputFormat

The input begins with a line containing two numbers: an integer ( n ) (the number of police) and a real number ( v ) (the common speed of the robber and the police). Each of the next ( n ) lines contains three real numbers: ( x_i ), ( y_i ) and ( \alpha_i ) (in radians) representing the initial coordinates of the ( i )-th police officer and the direction of his motion. It is guaranteed that all ( n+1 ) positions are distinct.

outputFormat

If there exists a direction in which the robber can escape (i.e. avoid interception from all police), output a single line containing the string YES. Otherwise, output two lines: the first line must contain NO, and the second line must contain a real number representing the maximum Euclidean distance from the origin at which the robber will be caught (if he picks his escape direction optimally). Answers within ( 10^{-6} ) absolute or relative error are accepted.

sample

1 1.0
1.0 0.0 0.0
YES

</p>