P8414 [THUPC 2022 Final] Simple Card Game
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:
1. First, the 52-card deck is evenly split into two halves of 26 cards each, and Alice and Bob each take one half.
2. The player who has the 7 of Spades places the 7 of Spades onto the table.
3. 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.
4. 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`.
Explanation/Hint
For $100\%$ 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