Indian Computing Olympiad

Training Material

Basic Graph Algorithms→Prisoners escape (Baltic Olympiad 2007)

A group of war prisoners are trying to escape from a prison. They have thoroughly planned the escape from the prison itself, and after that they hope to find shelter in a nearby village. However, the village (marked as B, see picture below) and the prison (marked as A) are separated by a canyon which is also guarded by soldiers (marked as S). These soldiers sit in their pickets and rarely walk; the range of view of each soldier is limited to exactly 100 meters. Thus, depending on the locations of soldiers, it may be possible to pass the canyon safely, keeping the distance to the closest soldier strictly larger than 100 meters at any moment.

          |                  S                  S
          |       S
       A  |                        S                         B
          |                S
          |                                S

Given the width and the length of the canyon and the coordinates of every soldier in the canyon, and assuming that soldiers do not change their locations, you have to determine whether prisoners can pass the canyon unnoticed.