#P8414. [THUPC 2022 决赛] 简单的卡牌游戏
[THUPC 2022 决赛] 简单的卡牌游戏
Problem Description
Alice and Bob have been playing many complicated games recently, so they want to play something simple to relax.
They remember a very simple game called “Bie Qi” (“憋七”, pinyin: bie qi). This game only needs a standard deck of playing cards. The traditional rules of “Bie Qi” are a bit complicated, so Alice and Bob decide to play a simplified version.
The deck used in the game contains four suits: Spades, Hearts, Clubs, and Diamonds. For each suit, there is exactly one card of each rank from 1 to 13, for a total of 52 cards.
The rules of the simplified game are as follows:
-
First, the 52-card deck is evenly split into two halves of 26 cards each, and Alice and Bob each take one half.
-
The player who has the 7 of Spades places the 7 of Spades onto the table.
-
Then, starting from the other player, they take turns. In each turn, the current player must choose one card from their hand and place it onto the table. A playable card must satisfy at least one of the following conditions:
-
The rank of the card is 7.
-
Among the cards currently on the table, there is a card with the same suit as the card to be played, and the ranks differ by exactly 1.
-
-
If the current player cannot play a card according to the rules, then that player loses and the other player wins. Otherwise, if both players have played all cards in their hands, the result is a draw.
Since building sequences in different suits is independent in this game, players often arrange the four 7s in a vertical line, and build sequences on both sides of each 7, forming a horizontal line for each suit.
It is known that both Alice and Bob are smart enough. Now you are given the initial hand of Alice and Bob. Please determine the result of the game when both players play optimally.
Input Format
Since one player’s hand determines the other player’s hand, the input contains only all cards in Alice’s hand.
The input consists of one line containing 26 space-separated strings, each representing one card in Alice’s hand.
Each card is given in the format suit + rank. The suit is one character: S for Spades, H for Hearts, C for Clubs, and D for Diamonds. The rank is a one- or two-digit number, with a minimum of 1 and a maximum of 13, without leading zeros. For example, the 7 of Spades is given as S7.
Output Format
Output one line containing a single string indicating the result of the game. If Alice can win, output Alice. If Bob can win, output Bob. If the result is a draw, output Draw.
S4 S6 S11 S13 H3 H4 H5 H6 H8 H10 H12 C2 C4 C5 C6 C8 C9 C11 C13 D1 D4 D5 D6 D8 D10 D12
Bob
S1 S2 S3 S4 S5 S6 S7 S8 S9 S10 S11 S12 S13 D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12 D13
Draw
H1 H2 H3 H4 H5 H6 H7 H8 H9 H10 H11 H12 C13 D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12 D13
Alice
Hint
For of the testdata, it is guaranteed that the input cards follow the format described above, and the 26 input cards are all distinct.
Translated by ChatGPT 5