#abc282b. B - Let's Get a Perfect Score

B - Let's Get a Perfect Score

Score : 200200 points

问题描述

设有 NN 名参与者,编号从 11NN,将参加一场包含 MM 道题目的比赛,题目编号从 11MM

对于整数 ii(取值范围在 11NN 之间)和整数 jj(取值范围在 11MM 之间),如果第 ii 位参与者字符串 SiS_i 的第 jj 个字符为 o,则表示该参与者能解第 jj 题;若为 x,则表示不能解这道题。

要求参与者两人一组。请输出能够共同解决所有 MM 道题目的参与者配对方式的数量。

更形式化地表述,打印满足条件的整数对 (x,y)(x, y) 的数量,其中 1x<yN1\leq x < y\leq N,且对于任意整数 jj(取值范围在 11MM 之间),参与者 xx 和参与者 yy 中至少有一人能解决第 jj 题。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

NN participants, numbered 11 to NN, will participate in a contest with MM problems, numbered 11 to MM.

For an integer ii between 11 and NN and an integer jj between 11 and MM, participant ii can solve problem jj if the jj-th character of SiS_i is o, and cannot solve it if that character is x.

The participants must be in pairs. Print the number of ways to form a pair of participants who can collectively solve all the MM problems.

More formally, print the number of pairs (x,y)(x,y) of integers satisfying 1x<yN1\leq x < y\leq N such that for any integer jj between 11 and MM, at least one of participant xx and participant yy can solve problem jj.

Constraints

  • NN is an integer between 22 and 3030, inclusive.
  • MM is an integer between 11 and 3030, inclusive.
  • SiS_i is a string of length MM consisting of o and x.

Input

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

NN MM

S1S_1

S2S_2

\vdots

SNS_N

Output

Print the answer.

Sample Input 1

5 5
ooooo
oooxx
xxooo
oxoxo
xxxxx

Sample Output 1

5

The following five pairs satisfy the condition: participants 11 and 22, participants 11 and 33, participants 11 and 44, participants 11 and 55, and participants 22 and 33.

On the other hand, the pair of participants 22 and 44, for instance, does not satisfy the condition because they cannot solve problem 44.

Sample Input 2

3 2
ox
xo
xx

Sample Output 2

1

Sample Input 3

2 4
xxxx
oxox

Sample Output 3

0

update @ 2024/3/10 11:49:44