8783: BZOJ4783:[Usaco2017 Open]Where

Memory Limit:128 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

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


输入格式

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.


输出格式

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


样例输入

4
ABBC
BBBC
AABB
ABBC

样例输出

2

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

and

BC
BC
BB
BC

提示

没有写明提示


题目来源

Silver&&鸣谢zyf2000提供译文

加入题单

算法标签: