PivotOJ

Dijamant

시간 제한: 1000ms메모리 제한: 512MB출처: COCI 2021-2022BOJ 24719

문제

Lovro has a table of nn rows and mm columns, where each cell is either . or #. By rotating a square by 45 a diamond shape is formed in the table. For a part of the table to be considered a diamond, its edge must also consist only of the character #, while its inside must be completely filled with . and it must be nonempty. Outside of a diamond any character is allowed. Diamonds come in different sizes, and the three smallest examples of a diamond are shown in the first sample.

Fabijan asked Lovro to tell him how many diamonds are there in the table, or else Lovro has to give him a cookie. Help Lovro by writing a program which counts the number of diamonds in his table.

입력

The first line contains positive integers nn and mm (1 ≤ n, m ≤ 2000), the number of rows and columns. Each of the next nn lines contains mm characters . or # which describe the table.

출력

In the only line print the number of diamonds in the table.

힌트

Clarification of the second example:

There is only one diamond in the table (the one with the smallest possible size). There appears to be another diamond containing it, but it is not considered a diamond because its inside is not completely filled with '.'. The shape on the right side of the table is also not a diamond because it’s missing a # character on its edge.

예제

예제 1

입력
7 25
.#...#....#....#.....#...
#.#..#...#.#...#....#.#..
.#...#..#...#..#...#...#.
.....#...#.#...#..#.....#
.....#....#....#...#...#.
.....#.........#....#.#..
.....#.........#.....#...
출력
3

예제 2

입력
11 17
.....#........#..
....#.#........#.
...#...#....#...#
..#.....#....#.#.
.#....#..#....#..
#....#.#..#......
.#....#..#.......
..#.....#........
...#...#.........
....#.#..........
.....#...........
출력
1

예제 3

입력
5 11
##.#.#.#.##
#.#.#.#.#.#
.#.#.#.#.#.
#.#.#.#.#.#
##.#.#.#.##
출력
14
코드를 제출하려면 로그인하세요.