Problem Statement
Alice and Bob are playing a game on an infinite grid. The grid is initially empty. Alice and Bob each have an infinite supply of checkers. Alice's checkers are red, Bob's are blue. In the first turn, Alice places one of her red checkers into the cell (0,0). The game continues by Bob and Alice taking alternate turns. In each turn, the current player places their checkers into some empty cells. The player must always add all the checkers that can be added in their turn by repeatedly applying the following rules:
- If cell (x-1,y-1) contains a checker of the other player and cell (x-2,y) is empty, add your checker into the cell (x,y).
- If cell (x-2,y) contains a checker of the other player and cell (x-1,y-1) is empty, add your checker into the cell (x,y).
Definition
- Class:
- CheckerExpansion
- Method:
- resultAfter
- Parameters:
- long, long, long, int, int
- Returns:
- String[]
- Method signature:
- String[] resultAfter(long t, long x0, long y0, int w, int h)
- (be sure your method is public)
Constraints
- t will be between 1 and 1000000000000 (10^12), inclusive.
- x0 and y0 will each be between 0 and 1000000000000 (10^12), inclusive.
- w and h will each be between 1 and 50, inclusive.
Examples
1
0
0
4
4
Returns: {"....", "....", "....", "A..." }This is the initial turn.5
4
1
3
4
Returns: {"A..", "...", "B..", ".B." }The checker that appears at the top row of this rectangle was placed by Alice just at the fifth turn.1024
1525
512
20
2
Returns: {"B...B...B...........", ".B.A.B.A.B.........." }53
85
6
5
14
Returns: {".....", ".....", "B....", ".B.A.", ".....", ".....", ".....", ".....", ".....", ".....", "B....", ".B...", "..B..", ".A.B." }