Robbery
Time limit1sMemory limit128 MB
Given time-stamped rectangular exclusions, find the robber's position at each time step where it is uniquely determined, moving at most one cell per step.
- Level
Medium6 of 10
- Topics
- Dynamic programming, Simulation, Matrix
- Solved
- No attempts yet
Problem
Inspector Robstop is very angry. Last night a bank was robbed, and the robber has not been caught. This has already happened for the third time this year, even though he did everything in his power to stop the robber: as quickly as possible, every road leading out of the city was blocked so that the robber could not escape. He then asked every resident to watch out for the robber, but the only messages he received were of the form "We don't see him."
This time he has had enough. Inspector Robstop decides to analyze how the robber could have escaped, and he asks you to write a program that takes all the information he could gather and works out where the robber was at each point in time.
The city where the bank was robbed happens to be rectangular. The roads leaving the city are blocked for a period of time , and during that period several observations of the form "the robber was not inside rectangle at time " are reported. Assuming that the robber moves at most one unit per time step (staying in place, or moving to one of the four orthogonally adjacent cells), your program must determine the exact position of the robber at every time step where it can be deduced.
Input
The input contains the descriptions of several robberies.
The first line of each description contains three integers , , (), where is the width and the height of the city, and is the length of time the city is locked down. The city is a grid; the point is the upper-left corner and is the lower-right corner.
The next line contains a single integer (), the number of messages the inspector received. Each of the following lines contains five integers , , , , . The integer is the time at which the observation was made (), and , , , are the left, top, right and bottom of the observed rectangular area, respectively (, ). Such a message means that the robber was not inside that rectangle (columns , rows ) at time .
The input is terminated by a case with , which must not be processed.
Output
For each robbery, first print the line "Robbery #k:", where is the number of the robbery (starting at 1). Then there are three possibilities.
If, considering the messages, it is impossible for the robber to still be in the city, print the line "The robber has escaped."
Otherwise, assume that the robber really is in the city. For every time step at which the exact location can be deduced, print one line of the form "Time step i: The robber has been at x,y.", where is the time step, is the column and is the row. Print these lines in increasing order of time .
If nothing can be deduced, print the line "Nothing known." and hope that the inspector will not get even angrier.
Print a blank line after each processed case.