## ECOO '19 R3 P2 - Array Game

View as PDF

Points: 10 (partial)
Time limit: 2.0s
Memory limit: 64M

Problem type

Alice and Bob have recently received a wonderful gift: a sorted array of positive integers! They have decided to create a new game using the array.

Starting with Alice, they take turns picking a positive element of the array and decreasing it by an arbitrary, non-zero amount. If a player cannot make a move on their turn, they lose. To make the game harder, they have also added the restriction that at the end of each player’s turn, the array must still be sorted in non-decreasing order.

Alice and Bob have been playing this game for hours, but they are not sure if the moves that they are making are optimal. Hence, they have asked you to analyze their games and see who should have won if both players played optimally.

#### Input Specification

The input will contain 10 datasets. Each dataset begins with an integer , the number of games they wish to analyze. game descriptions follow. Each game description consists of two lines. The first line contains an integer , the number of elements in the array. The next line contains integers , the original array. The array is guaranteed to be sorted in non-decreasing order.

For the first datasets, , .

For the first datasets, .

#### Output Specification

For each dataset, output a string of length . The -th character should be A if Alice should have won that game or B if Bob should have won that game.

#### Sample Input (Two Datasets Shown)

1
1
2
2
3
1 1 1
2
2 2

#### Sample Output

A
AB

#### Explanation of Sample Datasets

In the first dataset, Alice can win the game by decreasing the single array value to zero. In the second dataset, the only valid move in each turn of the first game is to decrease the left-most to zero. Since there are an odd number of terms, Alice will win. In the second game, Alice must decrease the first element. If Alice decreases it to zero, Bob can decrease the other element to a zero. If Alice decreases it to , Bob can decrease the second element to , which is a winning position for him.