#abc275c. C - Counting Squares

C - Counting Squares

Score : 300300 points

问题陈述

在二维平面上,对于整数 rrcc1199 之间,若 SrS_r 的第 cc 个字符为 #,则坐标 (r,c)(r,c) 处有一个棋子;若第 cc 个字符为 .,则该位置没有棋子。

求在这个平面上有多少个正方形的四个顶点上都放置了棋子。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

There is a two-dimensional plane. For integers rr and cc between 11 and 99, there is a pawn at the coordinates (r,c)(r,c) if the cc-th character of SrS_{r} is #, and nothing if the cc-th character of SrS_{r} is ..

Find the number of squares in this plane with pawns placed at all four vertices.

Constraints

  • Each of S1,,S9S_1,\ldots,S_9 is a string of length 99 consisting of # and ..

Input

The input is given from Standard Input in the following format:

S1S_1

S2S_2

\vdots

S9S_9

Output

Print the answer.

Sample Input 1

##.......
##.......
.........
.......#.
.....#...
........#
......#..
.........
.........

Sample Output 1

2

The square with vertices (1,1)(1,1), (1,2)(1,2), (2,2)(2,2), and (2,1)(2,1) have pawns placed at all four vertices.

The square with vertices (4,8)(4,8), (5,6)(5,6), (7,7)(7,7), and (6,9)(6,9) also have pawns placed at all four vertices.

Thus, the answer is 22.

Sample Input 2

.#.......
#.#......
.#.......
.........
....#.#.#
.........
....#.#.#
........#
.........

Sample Output 2

3

update @ 2024/3/10 11:34:45