Swap Game
Hazrat Ali
Alice and Bob are playing a game on an array aa of nn positive integers. Alice and Bob make alternating moves with Alice going first.
In his/her turn, the player makes the following move:
- If a1=0a1=0, the player loses the game, otherwise:
- Player chooses some ii with 2≤i≤n2≤i≤n. Then player decreases the value of a1a1 by 11 and swaps a1a1 with aiai.
Determine the winner of the game if both players play optimally.
The input consists of multiple test cases. The first line contains a single integer tt (1≤t≤2⋅104)(1≤t≤2⋅104) — the number of test cases. The description of the test cases follows.
The first line of each test case contains a single integer nn (2≤n≤105)(2≤n≤105) — the length of the array aa.
The second line of each test case contains nn integers a1,a2…ana1,a2…an (1≤ai≤109)(1≤ai≤109) — the elements of the array aa.
It is guaranteed that sum of nn over all test cases does not exceed 2⋅1052⋅105.
For each test case, if Alice will win the game, output "Alice". Otherwise, output "Bob".
You can output each letter in any case. For example, "alIcE", "Alice", "alice" will all be considered identical.
Bob Alice Alice
In the first testcase, in her turn, Alice can only choose i=2i=2, making the array equal [1,0][1,0]. Then Bob, in his turn, will also choose i=2i=2 and make the array equal [0,0][0,0]. As a1=0a1=0, Alice loses.
In the second testcase, once again, players can only choose i=2i=2. Then the array will change as follows: [2,1]→[1,1]→[1,0]→[0,0][2,1]→[1,1]→[1,0]→[0,0], and Bob loses.
In the third testcase, we can show that Alice has a winning strategy.
Solution :