#abc311b. B - Vacation Together

B - Vacation Together

Score : 200200 points

问题陈述

NN 名编号为 11NN 的人。
你得到了他们在接下来 DD 天的日程安排。第 ii 个人的日程安排由长度为 DD 的字符串 SiS_i 表示。如果 SiS_i 的第 jj 个字符是 o,表示第 ii 个人在第 jj 天有空;如果是 x,则表示他们在那天有事情。

从这 DD 天中,考虑选择一段所有人均为空闲的 连续 日子。
最多可以选择多少天?如果没有可选的日子,请报告 00

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

Problem Statement

There are NN people numbered 11 to NN.
You are given their schedule for the following DD days. The schedule for person ii is represented by a string SiS_i of length DD. If the jj-th character of SiS_i is o, person ii is free on the jj-th day; if it is x, they are occupied that day.

From these DD 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 00.

Constraints

  • 1N1001 \leq N \leq 100
  • 1D1001 \leq D \leq 100
  • NN and DD are integers.
  • SiS_i is a string of length DD consisting of o and x.

Input

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

NN DD

S1S_1

S2S_2

\vdots

SNS_N

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