#P8546. 小挖的 X 献身
小挖的 X 献身
Problem Description
Given an square matrix, compute the number of X’s in it.
An X is defined as a connected component filled with ’s and shaped like an X. Specifically, an X is made up of a left-leaning diagonal \ and a right-leaning diagonal /. You must ensure that the left-leaning diagonal and the right-leaning diagonal have the same length, and the X is centrally symmetric. The diagonal length must be greater than .
For example:
101
010
101
There is one X with diagonal length .
1001
0110
0110
1001
There are two X’s with diagonal lengths and .
10001
01010
00100
01010
00001
There is only one X with diagonal length .
Input Format
Line contains one positive integer .
The next lines each contain a string of length , describing a matrix.
Output Format
Output one line containing a non-negative integer, representing the number of X’s.
5
10001
01010
00100
01011
00011
2
Hint
For of the testdata, .
For of the testdata, .
For of the testdata, .
For of the testdata, .
Translated by ChatGPT 5