|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|1 초||128 MB||7||4||2||50.000%|
The game of darts involves throwing darts at a darts board. A darts board is divided into 20 sector, numbered from 1 to 20. Each segment contains single, double and triple scoring areas, so, for example, in segment number 5 it is possible to score 5, 10 or 15 points depending on the area which the dart lands in. In the centre of the board are two concentric circles: the bull’s eye (worth 50 points) and the outer bull (worth 25).
The game of 301 is played by two players, who take it in turns to throw groups of three darts. For each player, scoring does not start until they score a double (the bull’s eye counts as a double). At the end of each group of three darts the total of those darts is deducted from that player's score (which counts down from 301).
To finish the game, a player must make their score exactly 0 by scoring a double. Hence a turn finishes, and no more darts are thrown, once the score drops below 2. If the final score is 0 and the last dart was a double, then the game is over and that player is the winner, otherwise the game continues and the player’s score reverts to what it was at the beginning of the turn. Thus, if your score at the beginning of your turn is 10, then you should attempt to throw a double 5 and end the game. If you throw triple 3, single 9, single 10, or more than 10 then your turn ends and your score remains at 10. If you throw anything else then that throw is temporarily subtracted from your score and you continue attempting to end the game on a double. If you do then you win, if you don’t and your score drops below 2, then your turn ends and your score remains as it was at the beginning of your turn (in this case 10).
Write a program to score darts games.
Input consists of details for a series of games, with each game consisting of a series of throws occupying one or more lines. Each line (except possibly the last one in a game) consists of 10 throws where each throw consists of a specifier and a comma. A throw specifier is one of the following:
The sequence of games is terminated by a line consisting of a single ‘#’.
Output consists of several lines for each game. The first line contains the word ‘Game’, followed by a space and the game number — a running number starting at 1. This is followed by as many lines as necessary, with each line showing the scores at the end of each round. (Assume that the game starts with an empty zeroth round, so the first line is always ‘ 301 301’. Each line shows the scores for the two teams right justified in a field of width 5. The last line will contain the score of the losing team and the word ‘Wins’ right justified in a field of width 5 under the appropriate column. Separate successive games by a blank line.
D20,M,T20,T20,S19,B,T1,S5,T5,T20, T20,T20,T20,T20,T20,S1,S20,B,#, D20,M,T20,T20,S19,B,T7,S5,T5,T20, T20,T20,T20,T20,D20,#, #
Game 1 301 301 201 251 178 71 178 Wins Game 2 301 301 201 251 160 71 Wins 71