#C6369. Longest Star Segment Query
Longest Star Segment Query
Longest Star Segment Query
You are given a string s
representing a galaxy, where each character is either a star ('*') or a dash ('-'). You are also given several queries. Each query consists of two integers, l and r, representing the 1-indexed inclusive range in the string.
Your task is to determine, for each query, the length of the longest contiguous segment consisting only of star ('*') characters within the specified range.
Note: The input is read from standard input (stdin) and the output is written to standard output (stdout).
Input Format:
- The first line contains the string
s
. - The second line contains an integer
q
, the number of queries. - The following
q
lines each contain two space-separated integers,l
andr
.
Output Format:
- For each query, output a single integer on a new line representing the answer.
inputFormat
The input is provided via standard input (stdin) with the following format:
- The first line contains a string
s
composed of '*' and '-' characters. - The second line contains an integer
q
, the number of queries. - Each of the next
q
lines contains two space-separated integersl
andr
representing the left and right indices (1-indexed) of the query range.
outputFormat
For each query, print a single integer on a new line that is the length of the longest contiguous segment of '*' characters in the substring s[l...r]
.
*--**-*-
3
1 4
3 7
1 8
1
2
2
</p>