Under construction

Still being built. Things may change

Fastminton

Time limit2sMemory limit512 MB

Summary
Simulate a Fastminton match from a string of server and receiver point results, printing the score at each Q announcement until the match ends.
Level

Easy2 of 10

Topics
Simulation, Implementation
Solved
No attempts yet

Problem

The Regional Committee of Fastminton (CRLF) holds an annual tournament for this new and unusual sport derived from badminton. This year is the third edition of the main tournament.

The committee's former programmer, the director's nephew, built a system that records the result of every point in a match and saves it to a file. After he left, he left behind some faulty versions of his programs. The committee needs you to write a program that reads the results from these log files, so that the record of every exciting rally is not lost.

Here are the main rules of Fastminton. It is a shorter version of badminton with fewer games.

  • Every match is played by two players (opponents) on a court split in half by a net.
  • Players are identified by their position on the scoreboard (left player, right player).
  • A match consists of three games. The first player to win two games wins the match.
  • A player wins a game by reaching at least 5 points with a lead of at least 2 points over the opponent, or by being the first to reach 10 points.
  • The left player serves first in the first game. In every later game, the player who served first is the player who won the previous game.
  • Each rally gives one point to either the server or the receiver. The player who wins the point serves on the next rally.

Input

The input is a single line containing the complete sequence of events in a match. The line contains only the characters S (point won by the server), R (point won by the receiver), or Q (score announcement). The input never contains two score announcements in a row.

Output

Print one line for each score announcement (Q) found in the input, showing the current score.

If the match is still in progress, the line has the form GL (PL) - GR (PR). GL and GR are the numbers of games won by the left and right players. PL and PR are the current points of the left and right players. Append an asterisk (*) to the point count of the player who serves on the next rally.

If the match is over, the line has the form GL - GR. Append (winner) to the game count of the player who won the match.

Examples3

  1. Example 1

    Input
    SRSSQSSSSQRRSS
    
    Expected output
    0 (1) - 0 (3*)
    0 (0) - 1 (2*)
    
  2. Example 2

    Input
    SRSSQSSSSQRRSSQ
    
    Expected output
    0 (1) - 0 (3*)
    0 (0) - 1 (2*)
    0 - 2 (winner)
    
  3. Example 3

    Input
    RSRSSRRRRRRRRRRSSSSRRSQ
    
    Expected output
    2 (winner) - 0