The MagicianTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 14 Accepted Submission(s): 0
Problem Description In your quest to manifest your goals, it is essential that you establish a clear vision of what you wish to create and why you want to create it, before you take action. It is not simply enough to be motivated by ego (money, status, or fame) – you need to have a soul connection to your goals and intentions.
Background Magician Alice and Bob are playing Magic Duel, which is an amusing turn-based game. Here goes the tutorial to the game. Their strategy and the process of the game are determined and all you need to do is to figure out the result.
Game Structure The game consists of four separate areas containing several cards:Deck,Hand, Field, Grave. Deck The library of your cards – each turn you can draw a card from the top of the deck to your hand. Hand The collection of your available cards – each turn you can place a card from your hand to your field. Field The set of your active cards - the key to victory. Grave The place of all the discarded or destroyed cards. Notice that the Field and the Grave are public (i.e. known to each other), whereas the Deck and Hand are private. All these four areas are independent for each player.
Process of the Game Initially, each player draws five cards from the top of the deck, and two players play their own turns alternatively (Alice goes first). Each turn includes the following three phases in order. Draw Phase Draw a card from deck into hand. If the deck is empty this phase is skipped. Main Phase Select a card from hand, placing it into field and dealing corresponding effect. Player can choose to skip this phase. End Phase If the victory condition is reached by the player, he is announced to win immediately. Otherwise, switch the turn to the opponent.
Card Introduction Two players’ decks consist of same cards but in different order. In each deck lie 25 cards in 5 categories evenly. In other words, each kind of cards contains 5 identical cards. Here goes the introduction to the effects produced by these cards when played. Plain Draw a card from the deck (if the deck is empty it has no effect). Swamp Enemy player selects a card from his hand and discard it into his grave (if enemy’s hand is empty it has no effect). Mountain Select a card inside enemy’s field and destroy it, sending it into enemy’s grave (if enemy’s field is empty it has no effect). Island No effect. However, in enemy’s turn, when enemy intends to play a card (notice that you don’t know the card’s type because it hasn’t entered the field), you can discard an island from your hand firstly and discard another card from hand as cost to counter-attack the card, sending it to enemy’s grave and preventing it from dealing any effects. Forest Select a card in his own grave and recycle it into his hand (if the grave is empty it has no effect).
Victory Condition If the player has gathered five different kinds of cards in his field, he wins. If the game lasts 100 turns or both players have no cards in their decks or hands, it is a tie.
Strategy Play Strategy When selecting a card to play in Main Phase, the player labels his card in hand with three priority levels. High Priority There is no card of the same type in his own field and it has effect if played. Medium Priority There is no card of the same type in his own field but it has no effect if played. Low Priority There are cards of the same type in his own field. For the cards with the same priority, the player selects them in the following order: Swamp, Plain, Mountain, Forest and Island. Notice that if the player only has low-priority cards in hand he will skip the Main Phase.
Discard Strategy When player needs to discard a card from hand, this strategy works. The player will select the card with most occurrences in hand among all cards and discard it. For the cards with the same occurrences, player will select them in the following order: Island, Mountain, Plain, Swamp, Forest.
Destroy Strategy When Mountain is played by player himself, he will select the card with the least occurrences in enemy’s field among all cards in enemy’s field and destroy it. For the cards with the same occurrences, player will select them in the following order: Forest, Island, Mountain, Plain, Swamp.
Counter-attack Strategy When enemy intends to play a card, if enemy has gathered four kinds of card in his field and the number of the fifth kind of card in enemy’s grave is less than 5, player will choose to counter-attack. Obviously, player is required to have an Island and another card in his hand to have this done. The choice of cost card also follows the Discard Strategy.
Recycle Strategy When player plays Forest, he selects the card with the least occurrences in his own field and hand among all cards in his grave and recycles it into his hand. For the cards with the same occurrences, the player will select them in the following order: Forest, Swamp, Mountain, Island, Plain.
Input The first line contains a single integer $T$ ≤ 20000 indicating the number of tests. For each test case, input contains two lines with 25 integers between 0 and 4 (inclusive) separated by spaces, representing the cards in Alice and Bob’s decks from top to bottom. 0, 1, 2, 3, 4 respectively stand for Plain, Swamp, Mountain, Island, Forest.
Output For each test, start with “Case $i$:”, where $i$ indicates the number of the case, and then output a single line containing a string and an integer indicating the winner of the game (“Alice”, “Bob” or “Draw” if the game ties) and how many turns the game lasts, separated by spaces.
Sample Input 3
0 0 0 0 0 1 1 1 1 1 2 2 2 2 2 3 3 3 3
3 4 4 4 4 4
0 0 0 0 0 1 1 1 1 1 2 2 2 2 2 3 3 3 3
3 4 4 4 4 4
4 3 2 1 1 3 1 2 1 3 2 3 0 0 4 0 3 4 0
4 2 2 1 0 4
0 0 3 2 4 3 4 0 2 4 1 2 4 3 1 1 3 2 2
3 1 0 1 4 0
4 0 0 3 1 2 4 4 1 3 1 3 0 4 0 2 2 1 2
2 3 3 4 1 0
4 0 4 1 4 1 4 1 4 0 0 2 3 1 3 2 3 2 1
0 2 3 0 2 3
Sample Output Case 1: Bob 36
Case 2: Alice 17
Case 3: Alice 9
Source Statistic | Submit | Clarifications | Back
|