## Baltic OI '07 P1 - Escape

View as PDF

Points: 20 (partial)
Time limit: 0.6s
Memory limit: 16M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
##### Baltic Olympiad in Informatics: 2007 Day 1, Problem 1

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 , see picture below) and the prison (marked as ) are separated by a canyon which is also guarded by soldiers. These soldiers sit in their pickets and rarely walk; the range of view of each soldier is limited to exactly 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 meters at any moment.

You are to write a program which, 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, first determines whether prisoners can pass the canyon unnoticed. If this is impossible then the prisoners (having seen enough violence) would like to know the minimum number of soldiers that have to be eliminated in order to pass the canyon safely. A soldier may be eliminated regardless of whether he is visible to any other soldier or not.

#### Input Specification

The first line contains three integers , , and - the length and width of the canyon, and the number of soldiers, respectively. Each of the following lines contains a pair of integers and - the coordinates of -th soldier in the canyon . The coordinates are given in meters, relative to the canyon: the southwestern corner of the canyon has coordinates , and the northeastern corner of the canyon has coordinates , as seen in the picture above.

Note that passing the canyon may start at coordinate for any and end at coordinate for any . Neither nor need to be integer.

#### Output Specification

In the first and only line of the output file the program should print the minimum number of soldiers that have to be eliminated in order for the prisoners to pass the canyon safely. If the prisoners can escape without any elimination, the program should print (zero).

#### Sample Input

130 340 5
10 50
130 130
70 170
0 180
60 260

#### Sample Output

1