UOJ Logo 黑暗爆炸OJ

DARKBZOJ

#4783. [Usaco2017 Open]Where

统计 下载数据

Description

给出一个N*N的只含有A..Z的矩阵,一个合法的子矩阵定义为:只出现了两种不同的字符,其中一种字符的连通块
数量为1,另一种字符的连通块数量大于1。两个格子有公共边则它们连通。求不被其它任何合法的子矩阵所包含的
合法的子矩阵数量

Input

The first line of input contains N
, the size of the grid (1≤N≤20). The next N lines describe the image, each consisting of N
characters.

Output

Print a count of the number of PCLs in the image.

Sample Input

4
ABBC
BBBC
AABB
ABBC

Sample Output

2

In this example, the two PCLs are the rectangles with contents
ABB
BBB
AAB
ABB

and

BC
BC
BB
BC

Hint

Source

Silver&&鸣谢zyf2000提供译文