At the harbour of Barcelona P92480


Statement
 

pdf   zip

html

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 n sea waves surrounding him, each one modeled as a circle with center (xi, yi), initial radius ri, and propagation speed si, so that the radius of wave i as a function of the time t ≥ 0 is ri + si · t. Prof. Oak will choose any fixed direction and run “forever” at speed p. Will he be able to scape?

Input

Input consists of several cases, each with p and n, followed by n quadruples with xi, yi, ri and si. Assume 1 ≤ p ≤ 1000, 3 ≤ n ≤ 104, −1000 ≤ xi ≤ 1000, −1000 ≤ yi ≤ 1000, 1 ≤ ri ≤ 1000, and 0 ≤ si < p. Except for n, 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++