observe each tidy initially how about we characterize what a tidy in the matrix is. A bunch of matrix cells is called a tidy of tallness k with beginning at point (x,y) if: All cells in the set contain an "*". For each 1≤i≤k all cells with the line number x+i−1 and sections in range [y−i+1,y+i−1] should be a part of the set. All different cells cannot have a place with the set.
Correct answer will be upvoted else Multiple Downvoted. Computer science.
observe each tidy initially how about we characterize what a tidy in the matrix is. A bunch of matrix cells is called a tidy of tallness k with beginning at point (x,y) if:
All cells in the set contain an "*".
For each 1≤i≤k all cells with the line number x+i−1 and sections in range [y−i+1,y+i−1] should be a part of the set. All different cells cannot have a place with the set.
Presently Rick wants to know the number of tidies his n×m matrix contains. Assist Rick with tackling this issue.
Input
Each test contains at least one experiments. The primary line contains the number of experiments t (1≤t≤10).
The primary line of each experiment contains two integers n and m (1≤n,m≤500) — matrix size.
Next n lines of each experiment contain m characters ci,j — matrix substance. It is guaranteed that ci,j is either a "." or an "*".
It is guaranteed that the amount of n⋅m over all experiments doesn't surpass 5002 (∑n⋅m≤5002).
Output
For each experiment, print single integer — the total number of tidies in the matrix.
Step by step
Solved in 4 steps with 1 images