#abc311b. B - Vacation Together
B - Vacation Together
Score : points
问题陈述
有 名编号为 至 的人。
你得到了他们在接下来 天的日程安排。第 个人的日程安排由长度为 的字符串 表示。如果 的第 个字符是 o
,表示第 个人在第 天有空;如果是 x
,则表示他们在那天有事情。
从这 天中,考虑选择一段所有人均为空闲的 连续 日子。
最多可以选择多少天?如果没有可选的日子,请报告 。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are people numbered to .
You are given their schedule for the following days. The schedule for person is represented by a string of length . If the -th character of is o
, person is free on the -th day; if it is x
, they are occupied that day.
From these days, consider choosing some consecutive days when all the people are free.
How many days can be chosen at most? If no day can be chosen, report .
Constraints
- and are integers.
- is a string of length consisting of
o
andx
.
Input
The input is given from Standard Input in the following format:
Output
Print the maximum number of days that can be chosen, or 0
if no day can be chosen.
Sample Input 1
3 5
xooox
oooxx
oooxo
Sample Output 1
2
All the people are free on the second and third days, so we can choose them.
Choosing these two days will maximize the number of days among all possible choices.
Sample Input 2
3 3
oxo
oxo
oxo
Sample Output 2
1
Note that the chosen days must be consecutive. (All the people are free on the first and third days, so we can choose either of them, but not both.)
Sample Input 3
3 3
oox
oxo
xoo
Sample Output 3
0
Print 0
if no day can be chosen.
Sample Input 4
1 7
ooooooo
Sample Output 4
7
Sample Input 5
5 15
oxooooooooooooo
oxooxooooooooox
oxoooooooooooox
oxxxooooooxooox
oxooooooooxooox
Sample Output 5
5
update @ 2024/3/10 08:50:10