#abc282b. B - Let's Get a Perfect Score
B - Let's Get a Perfect Score
Score : points
问题描述
设有 名参与者,编号从 到 ,将参加一场包含 道题目的比赛,题目编号从 到 。
对于整数 (取值范围在 到 之间)和整数 (取值范围在 到 之间),如果第 位参与者字符串 的第 个字符为 o
,则表示该参与者能解第 题;若为 x
,则表示不能解这道题。
要求参与者两人一组。请输出能够共同解决所有 道题目的参与者配对方式的数量。
更形式化地表述,打印满足条件的整数对 的数量,其中 ,且对于任意整数 (取值范围在 到 之间),参与者 和参与者 中至少有一人能解决第 题。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
participants, numbered to , will participate in a contest with problems, numbered to .
For an integer between and and an integer between and , participant can solve problem if the -th character of 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 problems.
More formally, print the number of pairs of integers satisfying such that for any integer between and , at least one of participant and participant can solve problem .
Constraints
- is an integer between and , inclusive.
- 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.
Sample Input 1
5 5
ooooo
oooxx
xxooo
oxoxo
xxxxx
Sample Output 1
5
The following five pairs satisfy the condition: participants and , participants and , participants and , participants and , and participants and .
On the other hand, the pair of participants and , for instance, does not satisfy the condition because they cannot solve problem .
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