#P4010. [CTSC2012] 梭哈游戏
[CTSC2012] 梭哈游戏
Description
Xiao Y and Xiao Z have recently become obsessed with a poker game called Show Hand. Show Hand (Chinese: 梭哈, also called 沙蟹) is a poker game played with cards from to in spades, hearts, clubs, and diamonds (no jokers).
As with other poker games, the goal in Show Hand is to obtain the highest-ranking hand and win the pot. Each player first places an ante, then receives one hole card, which only the player can see. In the first round after the hole card is dealt, each player receives one upcard (face-up on the table, visible to everyone). The player with the highest upcard acts first and may bet, check, fold, or go all-in (“Show Hand”). Other players may call (if someone has gone all-in, they must also go all-in to call), raise, or fold. A player who folds cannot continue in the game, and the chips they have already bet cannot be retrieved. After an all-in, all players’ hands are immediately filled to cards for the final showdown. The second, third, and fourth rounds proceed in a similar way. Finally, each player compares hand ranks to determine the winner. The player with the highest hand wins.
All -card combinations are ranked from highest to lowest as follows:
-
Straight Flush: five consecutive cards of the same suit. Example: .
-
Four of a Kind: four cards of the same rank. Example: .
-
Full House: three cards of one rank plus a pair of another rank. Example: .
-
Flush: five cards of the same suit. Example: .
-
Straight: five consecutive ranks. Example: .
-
Three of a Kind: three cards of the same rank. Example: .
-
Two Pairs: two cards of one rank plus two cards of another rank. Example: .
-
One Pair: two cards of the same rank. Example: .
-
Zilch: none of the above; compare ranks to decide. Example: .
If the hand types are the same, use ranks and then suits to break ties (ranks have priority).
The order of ranks (from high to low) is . Note: when the cards are , the can be treated as the lowest rank. In this case it is still a straight, which is the lowest straight.
The order of suits (from high to low) is spades (♠) > hearts (♥) > clubs (♣) > diamonds (♦).
Examples:
-
(the former is a Straight Flush, which is higher).
-
(both are Full Houses; compare the triplets, beats ).
-
(both are Two Pairs and the higher pair is the same; compare the lower pair, beats ).
-
(both are Zilch with exactly the same ranks; compare the highest card’s suit, ).
-
(both are One Pair with identical ranks; the pair of s is the most significant component, so compare ).
During their game, Xiao Y wants to know the current situation in real time—namely, to compute his winning probability based on his current cards. However, his programming skills are limited. Can you help him?
Input Format
The first line contains positive integer , the number of cards currently in Xiao Y’s hand.
Each of the next lines contains two integers describing one card in Xiao Y’s hand: the first is the rank ( denotes , denotes , denotes , denotes ), and the second is the suit ( denotes spades, denotes hearts, denotes clubs, denotes diamonds).
Each of the next lines contains two integers describing one upcard in Xiao Z’s hand: the first is the rank ( denotes , denotes , denotes , denotes ), and the second is the suit ( denotes spades, denotes hearts, denotes clubs, denotes diamonds).
Output Format
Output exactly one line in the form A/B. Here and are two coprime natural numbers, and A/B is Xiao Y’s probability of winning in the current situation. In particular, if is , output 0/1.
5
2 1
2 2
2 3
2 4
3 1
1 1
1 2
1 3
3 2
42/43
Hint
Sample Explanation:
Xiao Y’s current hand type is Four of a Kind. If Xiao Z’s hole card is , he can also make Four of a Kind and win by rank. In all other cases, Xiao Y wins.
Constraints:
- For of the testdata, .
- For of the testdata, .
- For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号