#K5281. Maximum Consecutive Wins
Maximum Consecutive Wins
Maximum Consecutive Wins
Given n players and a performance string for each player, where each character in a string represents the outcome of a game (W for win and L for loss), determine the maximum number of consecutive wins each player has achieved.
For instance, if a player's performance is represented by the string WWLWLW
, the maximum consecutive wins is 2 (the first two games). Formally, if for a performance string s we define
\( \text{max_consecutive_wins}(s) = \max_{\text{segments of consecutive }W} (\text{length of the segment}) \),
compute this value for every player.
inputFormat
The input is given via standard input (stdin) and has the following format:
- The first line contains a single integer
n
(1 ≤ n ≤ 10^5), representing the number of players. - Each of the following
n
lines contains a non-negative-length string consisting only of the characters 'W' and 'L', representing a player’s performance. Note that a performance string may be empty.
outputFormat
Print a single line to standard output (stdout) containing n
integers separated by spaces. The i-th integer should be the maximum number of consecutive wins for the i-th player's performance.## sample
3
WWLWLW
WLWLWLL
WWWLLLWWW
2 1 3