#P6316. [COCI 2006/2007 #3] TROJKE
[COCI 2006/2007 #3] TROJKE
Problem Description
You are given an grid. Each cell may contain an uppercase letter, or it may be empty. No letter appears twice in the grid.
You want to find three letters that lie on the same straight line, such that the line passes through the centers of the three cells containing the letters.
Please determine how many such lines there are in the grid.
Input Format
The first line contains an integer , which is the side length of the grid.
The next lines each contain characters. Each character is either an uppercase letter or . (empty).
Output Format
Output one integer on a single line, representing the number of such lines in the grid.
4
...D
..C.
.B..
A...
4
5
..T..
A....
.FE.R
....X
S....
3
10
....AB....
..C....D..
.E......F.
...G..H...
I........J
K........L
...M..N...
.O......P.
..Q....R..
....ST....
0
Hint
Explanation for Sample 1
Note that in the first sample, any three letters are on the same line, so the answer is equivalent to .
Constraints
For of the testdata, it is guaranteed that , and no letter appears twice in the grid.
Notes
This problem is translated from COCI2006-2007 CONTEST #3 T3 TROJKE.
Translated by ChatGPT 5