407627: GYM102861 F Fastminton
Description
The Commission for the Regional deveLopment of Fastminton (CRLF) organizes annual tournaments of the novel and unusual game of Fastminton, a Badminton derivative. CRLF is proud to be organizing the third big tournament, that will be held this year.
The commission's former programmer has developed a computerized system to capture and store the results from the matches, point by point, to individual files. He left before being able to complete a parser to the files, so the CRLF requires your help to guarantee that all the records can be read from the written files, to avoid loosing years of thrilling game results.
A summary of the Fastminton rules was given to you to help in your tasks. It is, in essence, a shorter (or faster) version of Badminton:
- Fastminton matches are always played with two opposing players in a court that is divided by a net;
- Players are identified by their relative positions on the score (left and right player);
- A match is composed of three games. The player that reaches $$$2$$$ games is the winner;
- A game is won when a player reaches at least $$$5$$$ points with a at least a $$$2$$$ point difference from his opponent, or by reaching $$$10$$$ points (whichever comes first);
- The left player begins serving on the first game. For all other games, the serving player is the one that won the last game;
- Every round results in a point for the server or the receiver player. The player who scores serves the next round.
The input is comprised of a single line containing a sequence of characters. This line represents a complete match event sequence, and may contain the characters S (server point), R (receiver point) or Q (score announcement). The input does not contains consecutive score announcements.
OutputThe program must print a line containing the current score for each score announcement (Q) found on the input.
If the game is underway, the announcement will be in the format "GL (PL) - GR (PR)", where GL and GR are the number of games won by the left and right players, and PL and PR are the current points of the left and right players. An asterisk (*) must be appended to the point marked of the player that will serve in the next round.
If the game has finished, the announcement will follow "GL - GR" with the string "(winner)" added at the end of the game marked of the winner player.
ExamplesInputSRSSQSSSSQRRSSOutput
0 (1) - 0 (3*) 0 (0) - 1 (2*)Input
SRSSQSSSSQRRSSQOutput
0 (1) - 0 (3*) 0 (0) - 1 (2*) 0 - 2 (winner)Input
RSRSSRRRRRRRRRRSSSSRRSQOutput
2 (winner) - 0