102752: [AtCoder]ABC275 C - Counting Squares

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:9 Solved:0

Description

Score : $300$ points

Problem Statement

There is a two-dimensional plane. For integers $r$ and $c$ between $1$ and $9$, there is a pawn at the coordinates $(r,c)$ if the $c$-th character of $S_{r}$ is #, and nothing if the $c$-th character of $S_{r}$ is ..

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

Constraints

  • Each of $S_1,\ldots,S_9$ is a string of length $9$ consisting of # and ..

Input

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

$S_1$
$S_2$
$\vdots$
$S_9$

Output

Print the answer.


Sample Input 1

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

Sample Output 1

2

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

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

Thus, the answer is $2$.


Sample Input 2

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

Sample Output 2

3

Input

题意翻译

### 题目描述 给定一个 $9 \times 9$ 的矩阵。 矩阵中只包含 `.`, `#` 两种字符。 请求出以 `#` 作为四个顶点构成的正方形的数量。

Output

得分:300分

问题描述

在一个二维平面上。对于1到9之间的整数$r$和$c$,如果字符串$S_{r}$的第$c$个字符是#,则在坐标$(r,c)$处有一个棋子;如果字符串$S_{r}$的第$c$个字符是.,则没有棋子。

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

限制条件

  • 每个$S_1,\ldots,S_9$都是由#.组成的长度为9的字符串。

输入

输入从标准输入按以下格式给出:

$S_1$
$S_2$
$\vdots$
$S_9$

输出

打印答案。


样例输入1

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

样例输出1

2

以$(1,1)$,$(1,2)$,$(2,2)$和$(2,1)$为顶点的正方形的四个顶点都放置了棋子。

以$(4,8)$,$(5,6)$,$(7,7)$和$(6,9)$为顶点的正方形的四个顶点也放置了棋子。

因此,答案为$2$。


样例输入2

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

样例输出2

3

加入题单

算法标签: