11210-chinese Mahjong
Time limit:3.000 seconds
http://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=2151
Mahjong () is a game of Chinese origin usually played from four persons with tiles resembling dominoes and bearing various D Esigns, which are drawn and discarded until one player wins with a hand of four combinations of ' three tiles each and a Pai R of matching tiles.
A set of mahjong tiles would usually differ from place to place. It usually has at least 136 tiles, most commonly 144, although-sets originating from America or Japan would have more. The 136-tile Mahjong includes:
Dots:named as each tile consists of a number of circles. Each circle are said to represent copper (tong) coins with a square hole in the middle. In this problem, they ' re represented by 1T, 2T, 3T, 4 T, 5T, 6T, 7T, 8T and 9T.
Bams:named as each tile (except the 1 Bamboo) consists of a number of Bamboo sticks. Each stick are said to represent a string (suo) that holds a hundred coins. In this problem, they ' re represented by 1S, 2S, 3S, 4s, 5S, 6S, 7S, 8S and 9S.
Craks:named as each tile represents ten thousand (WAN) coins, or one hundred strings of one hundred coins. In this problem, they ' re represented by 1W, 2W, 3W, 4W, 5W, 6W, 7W, 8W and 9W.
Wind Tiles:east, South, West, and north. In this problem, they ' re represented by DONG, NAN, XI, BEI.
Dragon tiles:red, Green, and white. The term Dragon Tile is a western convention introduced from Joseph Park Babcock in He 1920 book introducing Mahjong to Ame Rica. Originally, these are tiles are said to have something to doing with the Chinese Imperial. The red tile means you the examination and thus'll be appointed a government official. The green tile means, consequently you become financially. The white tile (a clean board) means since your are now doing-you-should act like a good, incorrupt official. In this problem, they ' re represented by ZHONG, FA, BAI.
There are 9*3+4+3=34 kinds, with exactly 4 tiles to each kind, so There are 136 to total.
To whom May is interested, the 144-tile Mahjong also includes:
Flower Tiles:
Typically optional components to a set of the mahjong tiles, often contain artwork on their tiles. There are exactly one tile of each kind, so 136+8=144 to total. In this problem, we don ' t consider these tiles.
Chinese mahjong is very complicated. However, we are need to know very few of the "rules in" to solve this problem. A meld is a certain the set of tiles in one ' s hand. There are three kinds of melds you need to know (to who knows Mahjong, already are not Kong):
Pong:a set of three identical titles. Example:;.
Chow:a set of three suited tiles in sequence. All three tiles must is of the same suites. Sequences of higher length are not permissible (unless it forms more than one meld). Obviously, wind tiles and dragon tiles can never is involved in chows. Example:;.
Eye:the pair, while not a meld, was the final component to the standard hand. It consists of any two identical tiles.
A player wins the round by creating a standard mahjong hand. That means, the hand consists of a eye and several (possible zero) pongs and chows. Note this each title can involved in exactly one eye/pong/chow.
When a hand was one tile short of wining, the hand was said to be a ready hand, or more figuratively, ' on the pot '. The player holding a ready hand is said to being waiting for certain. For example