Emergency Room
Time limit1sMemory limit128 MB
Simulate patients taking the lowest free seat on arrival, track who sits within 2 metres for 20 consecutive minutes, and count infections spreading one day later.
- Level
Medium7 of 10
- Topics
- Simulation, Implementation, Geometry
- Solved
- No attempts yet
Problem
In the US, many people lack health insurance, which causes several kinds of problems. Most doctors will not treat patients without insurance, so those patients find it hard to get medical care. Emergency rooms, however, must treat every patient, because in their originally intended role they can be the difference between life and death. As a result, since the emergency room is the only place that must accept uninsured patients, uninsured people go there even for non-life-threatening conditions such as the flu or measles. Because the emergency room has to handle life-and-death cases first, these patients are not treated right away, and people carrying infectious diseases end up waiting together for many hours in a crowded emergency room. It is not clear that this is the best way to stop such diseases from spreading. In this problem we simulate how a disease spreads among the visitors of an emergency room.
The emergency room has seats, whose coordinates are given. You are given every arrival and departure of patients over time. When a patient arrives, they take the lowest-numbered seat that is free at that moment and stay in it until they leave. The same patient may come back later, and will then pick a new seat.
Initially, only patient 1 has the disease. The disease is transmitted from patient to patient when they sit within a distance of 2 metres of each other for at least 20 consecutive minutes (for example, from time 5 until time 25 is enough, but from time 5 until time 24 is not). If either of them leaves, the shared time is counted again from 0 (sitting next to each other twice for 10 minutes each does not count).
Once a patient is infected, they begin to transmit the disease the next day, that is, 1440 minutes after the moment of infection, and stay infectious forever afterward. Patient 1 is treated as having been infected the previous day, so patient 1 is infectious from time 0. Determine how many patients have the disease when the whole process ends.
Input
The first line contains the number of data sets. It is followed by data sets, each in the following form.
The first line of a data set contains three integers . is the number of patients (only patient 1 is infected at the start), is the number of seats in the emergency room, and is the number of patient visits.
This is followed by lines, each containing two real numbers , the coordinates (in metres) of the -th seat. Then come lines, each containing three integers : is the patient making the -th visit, is the arrival time (in minutes, from time 0), and is the departure time. The visits are sorted by non-decreasing arrival time. The input guarantees that at no moment are there more than patients in the emergency room at the same time. Also, if a patient arrives at exactly the departure time of another patient , then is considered to have already vacated the seat, so patient may sit there.
Output
For each data set, print "Data Set x:" on its own line, where is the number of the data set. Then, on the next line, print the total number of patients who are sick when the process ends. Print one blank line between two consecutive data sets.