#C8374. Beauty of Lantern Arrangement
Beauty of Lantern Arrangement
Beauty of Lantern Arrangement
This problem requires you to determine the beauty of a given lantern sequence for a festival. Each lantern is colored either red (R) or blue (B). The beauty of a sequence is defined as the maximum number of consecutive lanterns of the same color.
For example, in the sequence BBRBBRBBRR
, the longest contiguous substring with the same color is BB
(occurring multiple times) or a longer variant if available, and hence the beauty is 2.
The task is to compute this value for every provided sequence.
You can express the beauty mathematically as follows: if a sequence is represented by a string s with length n, then its beauty is \[ \max_{1 \leq i \leq n} \{ c_i \} \] where \(c_i\) is the length of the contiguous block of characters around position i with the same color.
inputFormat
The input begins with an integer t
representing the number of test cases. Each of the following t
lines contains a string consisting only of the characters B
and R
, representing the colors of the lanterns.
Input Format:
t s1 s2 ... st
outputFormat
For each test case, output a single integer on a new line indicating the beauty of the lantern arrangement (i.e., the maximum number of consecutive identical characters in the string).
## sample3
BBRBBRBBRR
RBBBBRRRRB
BRBRBRBRBR
2
4
1
</p>