#P1191. 矩形

矩形

Description

You are given an n×nn \times n matrix. In the matrix, some cells are colored white and some are colored black. Find the number of white rectangles in the matrix.

Input Format

The first line contains an integer nn, denoting the size of the matrix. Then follow nn lines, each containing nn characters. Each character is W\verb!W! or B\verb!B!. Here, W\verb!W! denotes a white cell, and B\verb!B! denotes a black cell.

Output Format

Output a single positive integer: the number of white rectangles.

4
WWBW
BBWB
WBWW
WBWB
15

Hint

For 30%30\% of the testdata, n50n ≤ 50. For 100%100\% of the testdata, n150n ≤ 150.

Translated by ChatGPT 5