#C10197. Maximum Walkable Distance
Maximum Walkable Distance
Maximum Walkable Distance
This problem asks you to calculate the maximum contiguous walkable distance for a series of trails.
Each trail is represented as a binary string, where the character 1
denotes a walkable segment and 0
denotes an obstacle. Your task is to find the length of the longest contiguous segment of 1's
for each given trail.
Formally, given a binary string \( s \), you are to compute:
[
\max{ k \mid s \text{ contains a contiguous segment of } k \text{ ones} }
]
For example, if a trail is represented by "110111
", the maximum walkable distance is 3.
inputFormat
The input is read from the standard input (stdin) and has the following format:
- The first line contains a positive integer
T
, which is the number of trails. - The following
T
lines each contain a binary string representing a trail.
outputFormat
For each trail, output a single line to the standard output (stdout) containing the maximum contiguous walkable distance for that trail.
## sample1
110111
3
</p>