Counting Ls

AtCoder
IDabc330_d
Time2000ms
Memory256MB
Difficulty
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. ## Constraints * $N$ is an integer between $2$ and $2000$, inclusive. * $S_i$ is a string of length $N$ consisting of `o` and `x`. ## Input The input is given from Standard Input in the following format: $N$ $S_1$ $S_2$ $\vdots$ $S_N$ [samples]
Samples
Input #1
3
ooo
oxx
xxo
Output #1
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)$
Input #2
4
oxxx
xoxx
xxox
xxxo
Output #2
0
Input #3
15
xooxxooooxxxoox
oxxoxoxxxoxoxxo
oxxoxoxxxoxoxxx
ooooxooooxxoxxx
oxxoxoxxxoxoxxx
oxxoxoxxxoxoxxo
oxxoxooooxxxoox
xxxxxxxxxxxxxxx
xooxxxooxxxooox
oxxoxoxxoxoxxxo
xxxoxxxxoxoxxoo
xooxxxooxxoxoxo
xxxoxxxxoxooxxo
oxxoxoxxoxoxxxo
xooxxxooxxxooox
Output #3
2960
API Response (JSON)
{
  "problem": {
    "name": "Counting Ls",
    "description": {
      "content": "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$, ",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc330_d"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "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.  \nThe states of the cells are given by $N$ strings of length $N$, ...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments