#Lutece0090. Harue's Child Mahjong Club
Harue's Child Mahjong Club
Migrated from Lutece 90 Harue's Child Mahjong Club
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
The background of this problem is about the on showing anime Saki Achiga-hen episode of Side-A
.
If it is not what you are interested in, read from the third paragraph, please.
Akato Harue is a former Achiga Girls Academy student who was one of the top players until she was defeated in a tournament final by a girl named Sukoya Kokaji. To rehabilitate herself, she formed a mahjong club for children at Achiga up until she was scouted by a company. Among all the children here, four kids stood out. They are Takakamo Shizuno, Atarashi Ako, Matsumi Kuro and Haramura Nodoka. Today Harue asks the kids to practice to win on self-draw on a concealed hand.
To simplify the roblem, we use some special rules for the mahjong here. (Generally, the rule is based on the rule of Japanese mahjong with some changes, since the background of this problem is a Japanese anime) Even if you are a greater mahjong player, please read the following description, since it could be so different from what we are familiar with. And one of difference is that there is no Pon
, Chi
, Kan
in this particular rule.
General idea about Mahjong
Mahjong is a game in which players compete to be the first to complete a hand(The explanation will be given in the following pages).
Each round, players begin with a random deal of thirteen tiles.
Particularly, the players take turns to take four consecutive tiles for three times from the tile wall, and then each one takes one additional tile, and those tiles are thought as initial tiles.
Players take turns drawing tiles in the tile wall and discarding one of the tiles he owns.
The player who completes a hand first wins.
The Tiles
The basic mahjong tiles are presented here. A full set of mahjong tiles contains four identical tiles of each of these.
Particularly, some tiles are also called ends.
Remember, there are each of the above tiles, for a total of .
To Build a Hand
A hand is fourteen tiles that a player owns, whict fits in some particular rules. If a player build a hand by drawing tiles and discarding, he wins.(Note: no stealing from other players)
For instance, a player hold thirteen tiles, and then he draws one, which makes the number of tiles added up to fourteen. If at this time, the tiles fits the rule to become a hand, he wins. And the game ends.
Standard hand
A Standard hand consists of Melds Pair ( identical tiles) for a total of tiles.
A Meld can be either a Run ( tiles in sequence) or a Set ( identical tiles).
Runs
A Run is tiles that run in sequence. That means three tiles in the same suit whose numbers are consecutive are called a Run.
Note that tiles DO NOT wrap around to form runs:
Note that Honors (Colors and Directions) CANNOT be made into runs.
Sets
A Set is 3 identical tiles used together.
Note that tiles from different suits CANNOT be mixed:
Pairs
A Pair is identical tiles used together.
Note that tiles from different suits CANNOT be mixed:
Special hands
Except for the standard hand, two special hands are also regarded as legal here
Now the problem is that given the information of the tile wall of each round, can you tell Harue who is the winner of the round if all of them use the best stategy. In another word, please find out who is the first one that form a hand, whether in a standard way or special way. And you can assume, all of they know the tiles the will take. The order of the four girls to take tile is, Takakamo Shizuno, Atarashi Ako, Matsumi Kuro and Haramura Nodoka.
Input
First line of the input is a single integer (), indicating they plays mahjong for rounds.
For each test case, there’s only one line, where gives the order of tiles.
The way to represent a tile are showing in the table.
Tile | Represent |
---|---|
Number 1 Number 9 | 1N 9N |
Stick 1 Stick 9 | 1S 9S |
Ball 1 Ball 9 | 1B 9B |
East South West North | EH SH WH NH |
Red White Green | rH wH gH |
Output
For each test case, output a single line in the form of For round X, NAME wins at turn K.
if someone wins at
this round, or For round X, a Draw Hand occurs.
if no one wins. here means the number of test cases starting
from , is the name of player who wins, is the times the winner take tiles after got her initial tiles.
Samples
2
1N 1N 1N 2N 1S 1S 1S 1S 2S 2S 2S 2S 3S 3S 3S 3S 3N 4N 5N 6N 4S 4S 4S 4S 5S 5S 5S 5S 6S 6S 6S 6S 7N 8N 9N 9N 7S 7S 7S 7S 8S 8S 8S 8S 9S 9S 9S 9S 9N gH gH gH 5N 3B 3N EH rH 8N 2B WH 4N wH 4N 4B 2B gH WH 3B WH 7B 5B 8N 8B 3N 7N 9B 8B 4N 3N rH 4B 9B 2B 5B wH 3B 7B 1B 6N 5N 7N rH 5B 6B 4B 6B 1B 2B 8B 7B 8B WH wH 1B 6N 3B 2N SH 1B NH EH EH NH SH 6B 2N 7N SH NH 5N 8N 9B 9N 2N 1N EH 4B 6N SH wH 6B 7B 5B 9B rH NH
7N rH 1S 9N 1B 4B 4S SH 8S 6N 4N 7S 8B 2S 2B gH SH 5S 9N EH NH 1N 4S 6N 7S 8N 2S 3B rH 2S 6S 5B 2B 4B 1B 5N 8S 6N 8B gH 5S 9S 6S 3S 6B 9S 3B NH gH 4N 7S 6S 1B 8B WH 6S 3S 2N 6B EH 9B 1N 8B 2B WH 1B 5N 9B 7B 1S 5B 5S 5B 4N 7B 2S 2N 9B 3N 7B 3N 7B 3N SH 3N EH SH 4N gH 1S 4S 1N 2B 5N 3B 8N 8N WH 8N WH rH 4S 9B 8S 9S 6B 7N wH 5B 9N 6N wH 2N 2N 3S 7N 7S 1N 4B 1S 9S rH wH 9N wH 5S 4B NH NH 7N 6B EH 3B 8S 5N 3S
For round 1, Takakamo Shizuno wins at turn 1.
For round 2, Matsumi Kuro wins at turn 8.
Note
Explanation for the first round:
Takakamo Shizuno’s initial tiles are 1N 1N 1N 2N 3N 4N 5N 6N 7N 8N 9N 9N 9N
, and then here comes 5N
. The four melds
here are 1N 1N 1N
,2N 3N 4N
, 6N 7N 8N
, 9N 9N 9N
, and the pair here is 5N 5N
. So she wins at turn . In fact, if she
takes any number tile, she wins.
For the second one, it is a random case.
The description and pictures are from the Internet with minor alterations.
Resources
Sichuan State Programming Contest 2012