Problem9129--ABC330 —— D - Counting Ls

9129: ABC330 —— D - Counting Ls

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB

Description

You are given an $N \times N$ grid. Let $(i,j)$ denote the cell in the $i$\-th row from the top and the $j$\-th column from the left.  
The states of the cells are given by $N$ strings of length $N$, $S_1, S_2, \dots, S_N$, in the following format:

-   If the $j$\-th character of $S_i$ is `o`, there is an `o` written in cell $(i,j)$.
-   If the $j$\-th character of $S_i$ is `x`, there is an `x` written in cell $(i,j)$.

Find the number of triples of cells that satisfy all of the following conditions:

-   The three cells in the triple are distinct.
-   All three cells have an `o` written in them.
-   Exactly two of the cells are in the same row.
-   Exactly two of the cells are in the same column.

Here, two triples are considered different if and only if some cell is contained in exactly one of the triples.

Input

The input is given from Standard Input in the following format:

```
$N$
$S_1$
$S_2$
$\vdots$
$S_N$
```

Output

Print the answer as an integer.

Constraints

-   $N$ is an integer between $2$ and $2000$, inclusive.
-   $S_i$ is a string of length $N$ consisting of `o` and `x`.

Sample 1 Input

3
ooo
oxx
xxo

Sample 1 Output

4

The following four triples satisfy the conditions:

  • (1,1),(1,2),(2,1)
  • (1,1),(1,3),(2,1)
  • (1,1),(1,3),(3,3)
  • (1,2),(1,3),(3,3)

Sample 2 Input

4
oxxx
xoxx
xxox
xxxo

Sample 2 Output

0

Sample 3 Input

15
xooxxooooxxxoox
oxxoxoxxxoxoxxo
oxxoxoxxxoxoxxx
ooooxooooxxoxxx
oxxoxoxxxoxoxxx
oxxoxoxxxoxoxxo
oxxoxooooxxxoox
xxxxxxxxxxxxxxx
xooxxxooxxxooox
oxxoxoxxoxoxxxo
xxxoxxxxoxoxxoo
xooxxxooxxoxoxo
xxxoxxxxoxooxxo
oxxoxoxxoxoxxxo
xooxxxooxxxooox

Sample 3 Output

2960

HINT

相同题目:ABC330

Source/Category