At the harbour of Barcelona P92480


Statement
 

pdf   zip

Professor Oak is attending some programming trainings at the harbour of Barcelona. It is the first day and Prof. Oak is a bit sleepy, so he decides to take a walk by the nearby beach. But, absorbed by the difficulty of the problems, he gets too close to the sea. And, when he realizes it, it is already too late. He starts running, but a large wave reaches his feet, making him fall. Even worse, dozens of turists start making fun of him. How humiliating...

Later, Prof. Oak is still drying his clothes, laughing at himself. “If at least something good could come out of this...”, he thinks. “Well, of course, a programming problem!” This one:

Consider Prof. Oak as a point located on the origin of an infinite two-dimensional flat world. There are nn sea waves surrounding him, each one modeled as a circle with center (xi,yi)(x_i, y_i), initial radius rir_i, and propagation speed sis_i, so that the radius of wave ii as a function of the time t0t \ge 0 is ri+sitr_i + s_i \cdot t. Prof. Oak will choose any fixed direction and run “forever” at speed pp. Will he be able to scape?

Input

Input consists of several cases, each with pp and nn, followed by nn quadruples with xix_i, yiy_i, rir_i and sis_i. Assume 1p10001 \le p \le 1000, 3n1043 \le n \le 10^4, 1000xi1000-1000 \le x_i \le 1000, 1000yi1000-1000 \le y_i \le 1000, 1ri10001 \le r_i \le 1000, and 0si<p0 \le s_i < p. Except for nn, all numbers are real, with at most three digits after the decimal point. Initially, Prof. Oak is strictly outside all the waves.

Output

For every case, print “safe” if Prof. Oak can escape, and “xof!” otherwise. The input cases do not have precision issues.

Observation

For your computations, use the type long double. And good luck!

Public test cases
  • Input

    7.2 5
    -5 0 3.9 0
    0 5 3.9 0
    0 -5 3.9 0
    5.5 4.5 2 0
    5.5 -4.5 2 0
    
    7.2 5
    -5 0 3.9 0
    0 5 3.9 0
    0 -5 3.9 0
    5.5 4.5 2 2.9
    5.5 -4.5 2 2.9
    
    10 2
    8 0 6 7
    -8 0 6 7
    

    Output

    safe
    xof!
    xof!
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Official solutions
    C++
    User solutions
    C++