eolymp
bolt
Try our new interface for solving problems
Problems

Form guide

Form guide

"Form guide" is one of the sport statistics that tells how well the team has been performing recently, usually in the form of last n matches. For example, if the results of the last \textbf{5} matches (home and away) are \textbf{H1-0} \textbf{A0-0} \textbf{H3-1} \textbf{A0-1} \textbf{A3-0} where the latest result shows in the last line, \textbf{Hx-y} = home match result with x is the score of the team, and y is the score of the opponent, and \textbf{Ay-x} = away match result where the score of the team we consider is the latter number. For the above results, the last-5 form of the team is \textbf{Last-5} \textbf{Overall Home Away} \textbf{WDWWL WW DWL} where \textbf{W=Win}, \textbf{D=Draw}, \textbf{L=Loss}. You are to write a program that shows the last-\textbf{n} match form of the team from the results, and the longest winning streak (number of consecutive wins in the overall results), the longest drawing streak (number of consecutive draws), and the longest losing streak (number of consecutive losses), respectively. In the last-\textbf{5} result above, the longest winning, drawing, and losing streaks of the overall results are \textbf{2}, \textbf{1}, \textbf{1}, respectively. \InputFile The first line of the input contains an integer \textbf{n}, where \textbf{n} is the number of team results (\textbf{1} ≤ \textbf{n} ≤ \textbf{100}). The following \textbf{n} lines describe the results. In each line, the first character '\textbf{H}' = home and '\textbf{A}' = away, followed by the scores \textbf{x-y} for home matches and \textbf{y-x} for away matches, where \textbf{x} is the score of the team we consider, and \textbf{y} is the score of the opponent. \OutputFile Write to the output \textbf{6} lines: the first line is the last-\textbf{n} overall (home and away) form illustrated with the sequence of characters (\textbf{W=Win}, \textbf{D=Draw}, \textbf{L=Loss}) with the rightmost is the most recent, the second line shows only home matches, and the third line shows only the away matches. The forth line to sixth line are the longest winning streak, the longest drawing streak, and the longest losing streak, respectively.
Time limit 1 second
Memory limit 64 MiB
Input example #1
5
H1-0
A0-0
H3-1
A0-1
A3-0
Output example #1
WDWWL
WW
DWL
2
1
1