#abc330d. D - Counting Ls
D - Counting Ls
Score : points
问题描述
给定一个 的网格。令 表示从上到下的第 行和从左到右的第 列的单元格。
单元格的状态由长度为 的 个字符串 给出,格式如下:
- 如果 的第 个字符是
o
,则在单元格 中写有一个o
。 - 如果 的第 个字符是
x
,则在单元格 中写有一个x
。
找出满足以下所有条件的单元格三元组的数量:
- 三元组中的三个单元格各不相同。
- 这三个单元格中都有
o
写在其中。 - 正好有两个单元格在同一行。
- 正好有两个单元格在同一列。
这里,两个三元组被认为是不同的,当且仅当恰好有一个单元格只被其中一个三元组包含。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given an grid. Let denote the cell in the -th row from the top and the -th column from the left.
The states of the cells are given by strings of length , , in the following format:
- If the -th character of is
o
, there is ano
written in cell . - If the -th character of is
x
, there is anx
written in cell .
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
- is an integer between and , inclusive.
- is a string of length consisting of
o
andx
.
Input
The input is given from Standard Input in the following format:
Output
Print the answer as an integer.
Sample Input 1
3
ooo
oxx
xxo
Sample Output 1
4
The following four triples satisfy the conditions:
Sample Input 2
4
oxxx
xoxx
xxox
xxxo
Sample Output 2
0
Sample Input 3
15
xooxxooooxxxoox
oxxoxoxxxoxoxxo
oxxoxoxxxoxoxxx
ooooxooooxxoxxx
oxxoxoxxxoxoxxx
oxxoxoxxxoxoxxo
oxxoxooooxxxoox
xxxxxxxxxxxxxxx
xooxxxooxxxooox
oxxoxoxxoxoxxxo
xxxoxxxxoxoxxoo
xooxxxooxxoxoxo
xxxoxxxxoxooxxo
oxxoxoxxoxoxxxo
xooxxxooxxxooox
Sample Output 3
2960
update @ 2024/3/10 01:14:00