DWITE, January 2012, Problem 4
Little Alice and Little Bob are playing with their favourite toys, Lego blocks. They have
Alice and Bob take turns removing one Lego block from the row, with Alice going first. At the beginning of a player's turn, if the blocks form a ladder – a sequence of either non-increasing or non-decreasing heights – that player loses. Given the heights of the initial row of blocks, determine who has the winning strategy, if they play optimally.
The input will contain 5 test cases, and each test case describes 3 games. The first line of each game contains a number
The output will contain 5 lines, with strings of 3 characters each. The A
if Little Alice wins, and B
if Little Bob wins.
Sample Input
2
2 3
3
0 2 2
4
1 2 4 3
Sample Output
BBA
Problem Resource: DWITE
Comments
what is a ladder how does a lego make a ladder
There's a trailing space after one of the n's in the test data.