This page is still under construction.

Parts of this page are still being built. What you see may change.

Earth Observation with a Mobile Robot Team

Time limit1sMemory limit128 MB

Summary
Simulate robots moving on piecewise-linear paths and report which ones receive the first robot's data through wireless contact over time.
Level

Medium6 of 10

Topics
Simulation, Graph, Union-find, Geometry
Solved
No attempts yet

Problem

A new type of mobile robot has been developed for environmental earth observation. It moves around on the ground, acquiring and recording various sorts of observational data using high-precision sensors. Robots of this type have short-range wireless communication devices and can exchange observational data with any robot nearby. They also have large-capacity memory units on which they record both the data they observe themselves and the data received from others.

Consider three robots A, B, and C, each with a circular wireless coverage area centered at its current position. Suppose A and B are close enough that A can transmit data to B and vice versa, while C is too remote to communicate with either. If B then moves toward C, B and C can start communicating, so B can relay observational data from A to C. In this way, if a team of robots moves properly, observational data quickly spreads over a large number of them.

Two robots can communicate at any instant when the distance between them is at most RR. Communication and relaying are instantaneous, so at any moment the data held by one robot immediately reaches every robot connected to it, directly or through intermediates. Your mission is to write a program that simulates how the data originally held by the first robot spreads among the team. Regardless of data size, assume the time necessary for communication is negligible.

Input

The input consists of multiple datasets, each in the following format.

N T R
nickname and travel route of the first robot
nickname and travel route of the second robot
...
nickname and travel route of the N-th robot

The first line contains three integers NN, TT, and RR: the number of robots, the length of the simulation period, and the maximum distance the wireless signal can reach. They satisfy 1≤N≤1001 \le N \le 100, 1≤T≤10001 \le T \le 1000, and 1≤R≤101 \le R \le 10.

The nickname and travel route of each robot are given in the following format.

nickname
t0 x0 y0
t1 vx1 vy1
t2 vx2 vy2
...
tk vxk vyk

nickname is a string of length between one and eight consisting only of lowercase letters. No two robots in a dataset share the same nickname. Each of the lines following the nickname contains three integers that satisfy:

  • 0=t0<t1<⋯<tk=T0 = t_0 < t_1 < \dots < t_k = T
  • −10≤vx1,vy1,…,vxk,vyk≤10-10 \le vx_1, vy_1, \dots, vx_k, vy_k \le 10

A robot moves on a two-dimensional plane. (x0,y0)(x_0, y_0) is its location at time 00. From time ti−1t_{i-1} to tit_i (for 0<i≤k0 < i \le k), its velocities in the xx and yy directions are vxivx_i and vyivy_i, respectively. The travel route is therefore piecewise linear and may self-overlap or self-intersect.

Each dataset satisfies the following conditions:

  • The distance between any two robots at time 00 is never exactly RR.
  • The xx- and yy-coordinates of every robot are always between −500-500 and 500500, inclusive.
  • Once any robot comes within R+10−6R + 10^{-6} of another, the distance between them becomes smaller than R−10−6R - 10^{-6} while the velocities are maintained.
  • Once any robot moves apart to R−10−6R - 10^{-6} from another, the distance between them becomes larger than R+10−6R + 10^{-6} while the velocities are maintained.
  • If one pair of robots mutually enter each other's wireless area at time tt, and another pair (possibly sharing one or two members) mutually leave each other's wireless area at time t′t', then ∣t−t′∣≥10−6|t - t'| \ge 10^{-6}.

Two or more robots may share the same location at the same time; they still move with their designated velocities.

The end of the input is indicated by a line containing three zeros.

Output

For each dataset, print the nickname of every robot that has received, by time TT, the observational data originally acquired by the first robot at time 00. Print each nickname on its own line in dictionary order, with no leading or trailing spaces. The first robot itself always counts as having the data. The set of such robots is uniquely determined.

Examples3

  1. Example 1

    Input
    3 5 10
    red
    0 0 0
    5 0 0
    green
    0 5 5
    5 6 1
    blue
    0 40 5
    5 0 0
    3 10 5
    atom
    0 47 32
    5 -10 -7
    10 1 0
    pluto
    0 0 0
    7 0 0
    10 3 3
    gesicht
    0 25 7
    5 -7 -2
    10 -1 10
    4 100 7
    impulse
    0 -500 0
    100 10 1
    freedom
    0 -491 0
    100 9 2
    destiny
    0 -472 0
    100 7 4
    strike
    0 -482 0
    100 8 3
    0 0 0
    
    Expected output
    blue
    green
    red
    atom
    gesicht
    pluto
    freedom
    impulse
    strike
    
  2. Example 2

    Input
    1 5 10
    alice
    0 0 0
    5 0 0
    0 0 0
    
    Expected output
    alice
    
  3. Example 3

    Input
    2 10 5
    cat
    0 0 0
    10 0 0
    dog
    0 3 0
    10 0 0
    0 0 0
    
    Expected output
    cat
    dog