Under construction

Still being built. Things may change

Radar Scopes

Time limit1sMemory limit128 MB

Summary
Given two radar sweeps five seconds apart, classify each plane as needing an equipment, intrusion, aloft, exited, or loss warning using distance and speed thresholds, then print sorted reports.
Level

Medium4 of 10

Topics
Implementation, Geometry, Simulation, Math
Solved
No attempts yet

Problem

You have joined a team of software designers building a new air-traffic control system. One of its functions is to automatically verify that the monitored aircraft's instruments are working, and to alert controllers to aircraft that are endangered, newly aloft, or possibly downed. You are to write a prototype of this function.

Your program is given a series of scenarios, each consisting of two radar sweeps. Each sweep detects between 00 and 100100 airplanes. Every time a sweep encounters a plane, the data-acquisition system captures an azimuth reading and a distance (in miles) from the radar, and also retrieves from the plane a squawk number and a ground speed (in miles/hour, an airspeed with wind corrections). Based on the two sweeps you must decide, for every plane in the radar's domain, whether a warning is required.

Assume a radar range (radius of coverage) of 1010 miles and instantaneous sweeps occurring 55 seconds apart, so the time between sweeps is Δt=5/3600\Delta t = 5/3600 hours.

An azimuth θ\theta and distance dd can be turned into plane coordinates (only relative positions matter for distances): let x=dsin⁡θx = d\sin\theta and y=dcos⁡θy = d\cos\theta.

Based on the radar and plane information, issue the following warnings.

  • equipment warning: For a plane present in both sweeps, let gˉ=(g1+g2)/2\bar g = (g_1+g_2)/2 be the average of the plane's two indicated airspeeds and let vv be the airspeed measured from the radar sweeps (the distance between the plane's two positions divided by Δt\Delta t). Warn if gˉ\bar g is not within 10%10\% of vv, i.e. if ∣gˉ−v∣>0.10 v|\bar g - v| > 0.10\,v.
  • new intrusion / new aloft: Consider a plane seen in the second sweep but absent from the first, now at distance d2d_2. The minimum distance it must travel to come onto the scope (shortest path) is 10−d210 - d_2 miles. With a 10%10\% margin it could have covered 1.10 g2 Δt1.10\,g_2\,\Delta t miles between the sweeps. If that is at least 10−d210 - d_2, the plane could have flown in from outside, so issue a new intrusion warning; otherwise it must have just taken off inside the scope, so issue a new aloft warning.
  • domain exited / domain loss: Consider a plane seen in the first sweep but not in the second, at distance d1d_1. The minimum distance to leave the scope is 10−d110 - d_1 miles. If 1.10 g1 Δt≥10−d11.10\,g_1\,\Delta t \ge 10 - d_1, the plane could have left the range, so issue a domain exited warning; otherwise it must have landed or crashed within the domain, so issue a domain loss warning.

Input

The first line of each scenario contains an integer N1N_1 (0≤N1≤1000 \le N_1 \le 100), the number of planes detected in the first sweep. The next N1N_1 lines each describe exactly one plane detected in sweep 1. Each description contains a squawk number, an azimuth, a distance, and a ground speed. The squawk number is an integer of 1 to 5 digits; the azimuth, distance, and ground speed are real numbers in the format XXX.XXX with leading and trailing zeroes as needed to fill all 6 places.

  • squawk number (0<S<327670 < S < 32767): a globally unique integer identifying each plane, used to match planes between sweeps 1 and 2.
  • azimuth (000.000≤A≤359.999000.000 \le A \le 359.999): the angle in degrees from North, sweeping toward the East. So East is 9090 degrees, South is 180180, and West is 270270.
  • distance (000.000≤D≤010.000000.000 \le D \le 010.000): the distance from the radar to the plane (extra distance due to altitude has already been removed by the radar's sensing logic).
  • ground speed (000.000≤G≤999.999000.000 \le G \le 999.999): the speed at which the plane is moving (in any direction) relative to the radar.

Immediately after the sweep-1 descriptions is a line with an integer N2N_2 (0≤N2≤1000 \le N_2 \le 100), the number of planes detected in the second sweep, followed by N2N_2 lines describing the sweep-2 planes in the same format.

The next scenario, if any, begins with N1N_1 on the following line. Read and process scenarios until end-of-file.

Output

For each scenario, first print Scenario # X, where XX is the scenario number, starting at 11 for the first scenario and increasing by 11.

Then, for each plane requiring a warning, print exactly one report line. Sort the report lines in ascending order of squawk number. On each line, write the squawk number right-justified in columns 1 to 5, then starting in column 6 one of the following warning strings (print the leading blanks and dashes exactly as shown):

  • " -- equipment warning"
  • " -- new intrusion"
  • " -- new aloft"
  • " -- domain exited"
  • " -- domain loss"

Print nothing for planes that require no warning.

Separate two consecutive scenarios with a single blank line (there is no extra blank line after the final scenario).

Examples5

  1. Example 1

    Input
    4
    222   060.111   007.600   095.000
    1496  203.122   009.444   598.991
    111   000.000   005.100   999.999
    013   333.333   006.711   188.448
    4
    111   001.000   003.713   999.999
    777   263.122   009.933   477.633
    333   083.014   004.300   127.122
    222   040.713   009.813   098.125
    
    Expected output
    Scenario # 1
       13 -- domain loss
      222 -- equipment warning
      333 -- new aloft
      777 -- new intrusion
     1496 -- domain exited
    
  2. Example 2

    Input
    2
    800   000.000   009.900   500.000
    801   000.000   002.000   050.000
    0
    0
    2
    900   000.000   009.800   600.000
    901   000.000   001.000   030.000
    
    Expected output
    Scenario # 1
      800 -- domain exited
      801 -- domain loss
    
    Scenario # 2
      900 -- new intrusion
      901 -- new aloft
    
  3. Example 3

    Input
    0
    0
    
    Expected output
    Scenario # 1
    
  4. Example 4

    Input
    2
    500   090.000   002.000   720.000
    700   090.000   002.000   100.000
    2
    500   090.000   003.000   720.000
    700   090.000   003.000   100.000
    
    Expected output
    Scenario # 1
      700 -- equipment warning
    
  5. Example 5

    Input
    2
    32000 090.000   009.800   600.000
    999   090.000   002.000   100.000
    3
    5     000.000   002.000   050.000
    999   090.000   003.000   100.000
    12345 000.000   009.900   500.000
    
    Expected output
    Scenario # 1
        5 -- new aloft
      999 -- equipment warning
    12345 -- new intrusion
    32000 -- domain exited