comprises of an upstanding board with n lines and m sections of cells, some vacant and some loaded up with squares of sand, and m non-negative integers a1,a2,… ,am (0≤ai≤n). In this adaptation of the issue, simulated
Correct answer will be upvoted else downvoted.
puzzle comprises of an upstanding board with n lines and m sections of cells, some vacant and some loaded up with squares of sand, and m non-negative integers a1,a2,… ,am (0≤ai≤n). In this adaptation of the issue, simulated intelligence will be equivalent to the number of squares of sand in segment I.
At the point when a cell loaded up with a square of sand is upset, the square of sand will tumble from its cell to the sand counter at the lower part of the section (every segment has a sand counter). While a square of sand is falling, different squares of sand that are adjoining anytime to the falling square of sand will likewise be upset and begin to fall. In particular, a square of sand upset at a cell (i,j) will go through all cells underneath and including the cell (i,j) inside the section, upsetting all nearby cells en route. Here, the cells adjoining a cell (i,j) are characterized as (i−1,j), (i,j−1), (i+1,j), and (i,j+1) (in case they are inside the network). Note that the recently falling squares can upset different squares.
In one activity you can upset any piece of sand. The riddle is tackled when there are basically
You are presently entrusted with tracking down the base measure of tasks to settle the riddle. Note that Little Dormi won't ever give you a riddle that is difficult to settle.
Input
The principal line comprises of two space-isolated positive integers n and m (1≤n⋅m≤400000).
Every one of the following n lines contains m characters, portraying each line of the board. On the off chance that a character on a line is '.', the comparing cell is unfilled. In case it is '#', the cell contains a square of sand.
The last line contains m non-negative integers a1,a2,… ,am (0≤ai≤n) — the base measure of squares of sand that requirements to fall beneath the board in every segment. In this rendition of the issue, computer based intelligence will be equivalent to the number of squares of sand in segment I.
Output :Print one non-negative integer, the base measure of tasks expected to settle the riddle.
Step by step
Solved in 3 steps with 1 images