#3778. 4783. [Usaco2017 Open]Where

4783. [Usaco2017 Open]Where

#4783. [Usaco2017 Open]Where

题目描述

给出一个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

数据范围与提示