Pro.ID22174 TitleSnooker Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22174 AC0 Submit0 Ratio- 时间&空间限制描述Recently, Hamster has been addicted to the Billiard Sports of Snooker. He convenes the game with his friend Doraemon. Snooker's scoring rules are complex. So Doraemon picks out a computer from his magical pocket. But the computer is short of software for statistic. Now it's your job to develop it. There are 22 balls in Snooker, including 15 red balls, 6 colorful balls (Black, Pink, Blue, Brown, Green, Yellow), and a white ball. Red balls and colorful balls are used to get points. White ball is used to hit down red balls and colorful balls. Before kick-off, it must decide which side plays first through throwing coin. The one who plays first can put the white ball at any position in kick-off area, to pot the red ball. Next, the game will go on at the position where the white ball stops. Any side must hit down a red ball first, and then choose any one colorful ball to pot. After hitting down a colorful ball, it must be pick out and put on the table at the original position (its position before kick-off). Next, pot red ball again, pot colorful ball, repeating such order, until all red balls have been hit down. After this the colorful balls must be potted at the order of yellow, green, brown, blue, pink and black. At this time, when a colorful ball has been hit down, it would disappear on the table (it's no need to put this colorful ball on the table again), until all colorful balls have been hit down and there's only one white ball on the table. Game would over. The course from beginning until all red balls and colorful balls have been hit down is called a frame. At this course, any one who can not hit down the correct ball successfully, hit down a wrong ball, or foul, it's the other side's turn to play. The result of a single frame is up to the scores of both sides, the one with more score win this frame. There are two ways to get the points: hit down the correct ball; the other striker fouls. Hitting down the red ball get 1 point; hitting down the yellow ball get 2 points; Green -- 3 pts, Brown -- 4 pts, Blue -- 5 pts, Pink -- 6 pts, Black -- 7 pts. So, the two strikers will do their best to hit down the black ball for more times if it's legal. When the striker's "ball on" (legal object ball) is a red, "the white ball didn't hit any red ball" incur a penalty of 4 points; the striker pot a color ball incur a penalty of the points of this color ball, and 4 points at least. For example, the penalty is 7 points if hitting a black ball, and 4 points for the yellow one. After hitting down a red ball, the striker should announce the color of the ball he wants to pot next before pot, or it will incur a penalty of 7 points. Similarly, when the striker's "ball on" is a color ball, the penalty will be 4 points if the striker didn't hit any ball. If the striker failed to hit the ball he specifies before, the penalty will be the points of the ball he specify, 4 points at least. If the ball he pot has the higher points than the one he specify, the penalty should be the point of the ball he pot, also 4 points at least. All penalties will not be minus from the striker who fouls, it will be added to the other striker. If the two strikers got the same points when one frame is terminated, then the black ball must be put on table again, and making an added decision competition. It must decide who pot first by "throwing coin". The one who hit down the black ball first or the other striker foul first will win this frame (the rule of calculating the scores is as above). The winner of one "game" is up to some "frame", and the winner of one "match" is up to some "game". In a match, Hamster and Doraemon will win the "throwing coin" by turns (Hamster won the first, Doraemon won the second, and so on). 输入There are multiple test cases. For each test case, there are two integer n and m. One "match" contains n "games", and one "game" contains m "frames". The player wins a single game when he got over half winning frames. Similarly, the player wins the match when he got over half winning games. The following lines show the events what happen in the match. In order to make the problem easier, we assume each pot effect to only one ball with the following events:
Input is terminated by "0 0". 输出Description Recently, Hamster has been addicted to the Billiard Sports of Snooker. He convenes the game with his friend Doraemon. Snooker's scoring rules are complex. So Doraemon picks out a computer from his magical pocket. But the computer is short of software for statistic. Now it's your job to develop it. There are 22 balls in Snooker, including 15 red balls, 6 colorful balls (Black, Pink, Blue, Brown, Green, Yellow), and a white ball. Red balls and colorful balls are used to get points. White ball is used to hit down red balls and colorful balls. Before kick-off, it must decide which side plays first through throwing coin. The one who plays first can put the white ball at any position in kick-off area, to pot the red ball. Next, the game will go on at the position where the white ball stops. Any side must hit down a red ball first, and then choose any one colorful ball to pot. After hitting down a colorful ball, it must be pick out and put on the table at the original position (its position before kick-off). Next, pot red ball again, pot colorful ball, repeating such order, until all red balls have been hit down. After this the colorful balls must be potted at the order of yellow, green, brown, blue, pink and black. At this time, when a colorful ball has been hit down, it would disappear on the table (it's no need to put this colorful ball on the table again), until all colorful balls have been hit down and there's only one white ball on the table. Game would over. The course from beginning until all red balls and colorful balls have been hit down is called a frame. At this course, any one who can not hit down the correct ball successfully, hit down a wrong ball, or foul, it's the other side's turn to play. The result of a single frame is up to the scores of both sides, the one with more score win this frame. There are two ways to get the points: hit down the correct ball; the other striker fouls. Hitting down the red ball get 1 point; hitting down the yellow ball get 2 points; Green -- 3 pts, Brown -- 4 pts, Blue -- 5 pts, Pink -- 6 pts, Black -- 7 pts. So, the two strikers will do their best to hit down the black ball for more times if it's legal. When the striker's "ball on" (legal object ball) is a red, "the white ball didn't hit any red ball" incur a penalty of 4 points; the striker pot a color ball incur a penalty of the points of this color ball, and 4 points at least. For example, the penalty is 7 points if hitting a black ball, and 4 points for the yellow one. After hitting down a red ball, the striker should announce the color of the ball he wants to pot next before pot, or it will incur a penalty of 7 points. Similarly, when the striker's "ball on" is a color ball, the penalty will be 4 points if the striker didn't hit any ball. If the striker failed to hit the ball he specifies before, the penalty will be the points of the ball he specify, 4 points at least. If the ball he pot has the higher points than the one he specify, the penalty should be the point of the ball he pot, also 4 points at least. All penalties will not be minus from the striker who fouls, it will be added to the other striker. If the two strikers got the same points when one frame is terminated, then the black ball must be put on table again, and making an added decision competition. It must decide who pot first by "throwing coin". The one who hit down the black ball first or the other striker foul first will win this frame (the rule of calculating the scores is as above). The winner of one "game" is up to some "frame", and the winner of one "match" is up to some "game". In a match, Hamster and Doraemon will win the "throwing coin" by turns (Hamster won the first, Doraemon won the second, and so on). Input There are multiple test cases. For each test case, there are two integer n and m. One "match" contains n "games", and one "game" contains m "frames". The player wins a single game when he got over half winning frames. Similarly, the player wins the match when he got over half winning games. The following lines show the events what happen in the match. In order to make the problem easier, we assume each pot effect to only one ball with the following events:
Input is terminated by "0 0". Output For each test case, output "Error!" if there are any illegal situation appearing in the input. Otherwise, output the scores of each frames, and the winner of the match (see the sample output). Output a blank line between each test case. Sample Input 1 1 Sample Output 155-4 Source 样例输入1 1 样例输出155-4 作者 |