#T169. 流感传染
流感传染
Description
A group of susceptible individuals lives in a dormitory area arranged in a grid. The dormitory area is an n*n matrix, where each grid point represents a room that may be occupied by a person or left empty. On the first day, some of the rooms contain people who have contracted the flu. Each subsequent day, those who have the flu will infect their neighbors (those already infected remain unchanged), while empty rooms cannot spread the infection.
Please output the number of people who have contracted the flu by the m-th day.
Input Format
The first line contains a number n (n ≤ 100), representing the size of the dormitory rooms as an n*n matrix.
The next n lines each contain n characters:
- '.' indicates that the room is occupied by a healthy person on the first day.
- '#' indicates that the room is empty.
- '@' indicates that the room is occupied by a person who has contracted the flu on the first day.
The following line contains an integer m (m ≤ 100).
Output Format
Output the number of people who have contracted the flu by the m-th day.
5
....#
.#.@.
.#@..
#....
.....
4
16