P29337 [洛谷] [COCI2006-2007#3] TROJKE
入门
题目描述

Problem Description

Given an $n \times n$ grid paper, each cell may contain a capital letter or be empty. No letter will appear twice in the grid paper.

You need to find three letters on a line such that the line passes through the centers of the cells containing these three letters.

Calculate how many such lines exist on the grid paper.

Input Format

The first line of input contains an integer $n$, representing the side length of the grid paper.

The next $n$ lines, each containing $n$ characters, may be a capital letter or a dot (indicating an empty cell).

Output Format

Output a single integer on one line, representing the number of such lines on the grid paper.

Sample Input and Output

Sample Input #1

4
...D
..C.
.B..
A...

Sample Output #1

4

Sample Input #2

5
..T..
A....
.FE.R
....X
S....

Sample Output #2

3

Sample Input #3

10
....AB....
..C....D..
.E......F.
...G..H...
I........J
K........L
...M..N...
.O......P.
..Q....R..
....ST....

Sample Output #3

0

Notes

Sample 1 Explanation

Note that in the first sample, any three letters are on the same line, resulting in an answer equivalent to $C^4_3 = 4$.


Data Size and Constraints

For $100\%$ of the data, it is guaranteed that $3 \le n \le 100$, and no letter will appear twice in the grid paper.


Notes

This problem is translated from COCI2006-2007 CONTEST #3 T3 TROJKE.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 ...D ..C. .B.. A...
样例输出
4