Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Easy Prediction

By shefin · Limits 1s, 512 MB

Alice and Bob have an array aa of nn integers. They decide to play a game with the array. In one move,

  • One must choose an index ii such that ai>0a_i > 0. After that, he sets the value of aia_i to 00.

Alice and Bob make alternating moves: Alice makes the first move, Bob makes the second move, Alice makes the third one, and so on. If a player can't make any move, he/she loses. Who will win if both play optimally?


The first line of the input contains one integer t(1t1000)t(1\leq t\leq 1000), the number of test cases.

In each test case, the first line contains an integer n(1n50)n(1\leq n\leq50), the number of elements in aa.
The next line contains nn integers a1,a2,,an(0ai20)a_1, a_2, \dots , a_n (0\leq a_i\leq 20), where aia_i is the ithi^{th} element of aa.


For each test case, print the name of the winner in a single line. If Alice wins, print “Alice” (without quotes) otherwise print “Bob” (without quotes).


0 0 0
0 5
2 0 6

Sample Explanation:

In the 1st1^{st} case, Alice can’t make the first move. So, Bob wins.
In the 2nd2^{nd} case, Alice sets the value of a2a_2 to 00 in the first move. As a result, Bob can’t make the second move. So, Alice wins.
In the 3rd3^{rd} case, Alice can set the value of a1a_1 to 00 in the first move. After that, Bob will set the value of a3a_3 to 00. As a result, Alice can’t make the third move. So, Bob wins. It can be showed that, if Alice chooses index 33 in the first move, Bob will still win.



96% Solution Ratio

Tonoy1010xEarliest, 6M ago

rayhan28Fastest, 0.0s

Tonoy1010xLightest, 131 kB

aNkanpy.pritomShortest, 116B


Login to submit


If the count of non-zero elements is odd, Alice wins. Otherwise, Bob wins. Why? Find out yourself.

Related Contests

Toph uses cookies. By continuing you agree to our Cookie Policy.