#P10398. 『STA - R5』Remove and Decrease Game

『STA - R5』Remove and Decrease Game

Problem Description

You are given nn piles of stones. The ii-th pile contains aia_i stones, and it is guaranteed that ai\bm{a_i} are all distinct.

Alice and Bob take turns performing one of the following two operations, and after the operation they remove any pile whose number of stones becomes 00. Alice moves first. The player who cannot make a move loses.

  • Take one stone from every pile.
  • Remove the pile with the smallest number of stones.

Assuming both players play optimally, determine who will win. You need to answer TT queries.

Input Format

This problem contains multiple queries in a single test case.

The first line contains a positive integer TT, the number of queries.

For each query: the first line contains a positive integer nn, the number of piles. The second line contains nn positive integers, where the ii-th integer represents aia_i.

Output Format

For each query, output one line containing Alice or Bob, indicating who will win.

3
1
7
3
6 7 3
4
2 8 5 6

Alice
Bob
Alice

Hint

This problem uses bundled tests.

For 100%100\% of the testdata:

  • 1T2×1051 \le T \le 2 \times 10^5
  • 1n2×1051 \le n \le 2 \times 10^5
  • 1ai1091 \le a_i \le 10^9
  • aia_i are pairwise distinct;
  • n2×105\sum n \le 2 \times 10^5

The detailed subtask distribution is as follows:

Subtask ID Constraints Score
1 n2n \le 2 33
2 ai1000a_i \le 1000, n104\sum n \le 10^4 2323
3 n22×106\sum n^2 \le 2 \times 10^6
4 108ai10910^8 \le a_i \le 10^9
5 No special constraints 2828

Translated by ChatGPT 5