Lý thuyết trò chơi
D. Even-Odd Game
During their New Year holidays, Alice and Bob play the following game using an array of integers:
- Players take turns, Alice moves first.
- Each turn a player chooses any element and removes it from the array.
- If Alice chooses even value, then she adds it to her score. If the chosen value is odd, Alice's score does not change.
- Similarly, if Bob chooses odd value, then he adds it to his score. If the chosen value is even, then Bob's score does not change.
If there are no numbers left in the array, then the game ends. The player with the highest score wins. If the scores of the players are equal, then a draw is declared.
For example, if and , then the game could go as follows (there are other options):
- On the first move, Alice chooses and get two points. Her score is now . The array is now .
- On the second move, Bob chooses and get five points. His score is now . The array is now .
- On the third move, Alice chooses and get no points. Her score is now . The array is now .
- On the last move, Bob chooses and get three points. His score is now . The array is empty now.
- Since Bob has more points at the end of the game, he is the winner.
You want to find out who will win if both players play optimally. Note that there may be duplicate numbers in the array.
The first line contains an integer () — the number of test cases. Then test cases follow.
The first line of each test case contains an integer () — the number of elements in the array .
The next line contains integers () — the array used to play the game.
It is guaranteed that the sum of over all test cases does not exceed .
For each test case, output on a separate line:
- "Alice" if Alice wins with the optimal play;
- "Bob" if Bob wins with the optimal play;
- "Tie", if a tie is declared during the optimal play.
4 4 5 2 7 3 3 3 2 1 4 2 2 2 2 2 7 8
Bob Tie Alice Alice
Nhận xét
Đăng nhận xét