407627: GYM102861 F Fastminton

Memory Limit:1024 MB Time Limit:0 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

F. Fastmintontime limit per test0.25 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard output

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.
Input

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.

Output

The 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.

ExamplesInput
SRSSQSSSSQRRSS
Output
0 (1) - 0 (3*)
0 (0) - 1 (2*)
Input
SRSSQSSSSQRRSSQ
Output
0 (1) - 0 (3*)
0 (0) - 1 (2*)
0 - 2 (winner)
Input
RSRSSRRRRRRRRRRSSSSRRSQ
Output
2 (winner) - 0

加入题单

算法标签: