BSSPC '22 P3 - Searching for Seats
View as PDFYou're running late for your favorite club because of hall traffic. Of course it's the computer club! When you finally arrive, the club has already started and you must make the all-important decision of where to sit.
The classroom can be represented by an  grid, with 
 rows and 
 columns of seats. Additionally, a person sitting in any of the up to 
 seats surrounding a seat is considered to be sitting next to the person in the middle.
Naturally, you want to sit next to some of your friends, and as it happens, all  students attending that day are your friends!
Given the coordinates  of all 
 of your friends, find the number of possible seats that you can sit in, where you sit next to at least 
 friends.
Note that a seat can only fit one person, either you or one of your friends. Please do not push your friends off of chairs.
Constraints
Input Specification
The first line of input contains three integers, , 
, and 
.
The next  lines contain two integers each, the 
 containing 
 and 
.
Output Specification
Output a single integer, the number of seats you can sit in where you are next to at least  friends.
Sample Input
3 4 5
1 2
1 4
2 1
3 1
3 3
Sample Output
3
Explanation
The grid is shown below:
.#.#
#xx.
#x#.
Your classmates are marked by #, and seats you can sit in that are next to at least  friends are marked by 
x.
Comments