Rough ocean - MarisaOJ: Marisa Online Judge

Rough ocean

Time limit: 2000 ms
Memory limit: 256 MB
The ocean can be represented as a matrix $A$ of size $n \times n$. There are some storms, they are represented as character `X`. The storms have the radius of $r$. In other words, if a storm is at $(i, j)$, every $(i', j')$ with $|i-i'|+|j-j'| \le r$ will be affected. Count the number of unaffected areas. ### Input - The first line contains 2 integers $n, r$. - The next $n$ lines represents $A$, each line contains a string of length $n$ consisting only characters `.` and `X`. ### Output - Print the number of unaffected areas. ### Constraints - $1 \le n \le 5000$. ### Example Input: ``` 4 1 ..X. X... .... ..X. ``` Output: ``` 4 ```