report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Rough ocean - FlandreOJ: Flandre 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 ```
Multisource BFS / Dijkstra
Rough ocean
Restaurant
Escape from... dolls 2
Power plant
Iceberg
Topic
Graph
Shortest path
Rating 1000
Solution (0) Solution