#P17092. [ICPC 2017 Qingdao R] Battle in Two Pairs of Heroes
[ICPC 2017 Qingdao R] Battle in Two Pairs of Heroes
Problem Description
In the game of Warcraft, Alice has two heroes A1 and A2, and Bob has two heroes B1 and B2. The health points of A1 and A2 (resp. B1 and B2) are and (resp. and ) respectively. The heroes with positive health points are surviving, and the heroes with zero or negative health points are dead. The goal of the game is to kill both of the opponent’s heroes.
Alice and Bob take turns to move. In Alice’s turn, if A1 (resp. A2) is surviving, then A1 (resp. A2) can decrease B1’s health points by (resp. ), or decrease B2’s health points by (resp. ). If both A1 and A2 are surviving, then there are 4 possible actions in Alice’s turn:
- Decrease B1’s health points by ;
- Decrease B2’s health points by ;
- Decrease B1’s health points by and decrease B2’s health points by ;
- Decrease B1’s health points by and decrease B2’s health points by .
Similarly, in Bob’s turn, if B1 (resp. B2) is surviving, then B1 (resp. B2) can decrease A1’s health points by (resp. ), or decrease A2’s health points by (resp. ). If both B1 and B2 are surviving, then there are 4 possible actions in Bob’s turn:
- Decrease A1’s health points by ;
- Decrease A2’s health points by ;
- Decrease A1’s health points by and decrease A2’s health points by ;
- Decrease A1’s health points by and decrease A2’s health points by .
Both player play optimally. Your task is to find out the winner of the game.
Input Format
The first line is the number of test cases up to 40. For each test case, there is a line containing 12 integers , , , , , , , , , , and . All the integers are positive and less than 100.
Output Format
For each test case, if Alice has a winning strategy even if Bob moves first, then output “Alice wins”; if Bob has a winning strategy even if Alice moves first, then output “Bob wins”; if the player who moves first has a winning strategy, then output “It depends”.
3
3 3 3 8 1 2 2 1 2 1 1 2
4 10 10 4 1 2 2 1 2 1 1 2
5 12 12 5 2 1 1 2 1 2 2 1
It depends
Alice wins
Bob wins