TopCoder problem "ChessTraining" used in SRM 384 (Division I Level Three)



Problem Statement

    Alice and Bob are hobby chess players. They would like to become the best in the world so they are training a lot. Today they are going to play the following game with queens on a 100 x 100 chessboard to improve their offensive skills.



In each turn a player must choose one queen and move with it. From position (x, y) a queen can be moved to (x - k, y) or (x, y - k) or (x - k, y - k), where k > 0. (Queens can move through squares containing other queens, and multiple queens can coexist on a single square). The two players alternate turns, and Alice goes first. The first player who moves any queen to the position (0,0) will become the winner. You are given the initial positions of the queens in the int[]s x and y, where (x[i], y[i]) is the position of the i-th queen. Suppose Alice and Bob are playing optimally. Return "Alice will win" if Alice can win or "Bob will win" otherwise (all quotes for clarity).
 

Definition

    
Class:ChessTraining
Method:game
Parameters:int[], int[]
Returns:String
Method signature:String game(int[] x, int[] y)
(be sure your method is public)
    
 

Constraints

-x will contain between 1 and 50 elements, inclusive.
-y will contain the same number of elements as x.
-Each element of x and y will be between 0 and 99, inclusive.
-No queen will be at position (0,0) at the beginning.
 

Examples

0)
    
{3,4}
{3,5}
Returns: "Alice will win"
Alice can move a queen from (3,3) to (0,0) to win in her first move.
1)
    
{1}
{2}
Returns: "Bob will win"
No matter how Alice moves the queen, Bob can win in the next move.
2)
    
{5,7,3,5}
{8,3,7,8}
Returns: "Bob will win"
3)
    
{3,3,18,6,0,14,1}
{4,4,11,9,9,9,9}
Returns: "Alice will win"
4)
    
{1,2}
{3,3}
Returns: "Alice will win"
5)
    
{3,4,3}
{2,2,1}
Returns: "Bob will win"

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=6866

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=10808&pm=6866

Writer:

rasto6sk

Testers:

PabloGilberto , Olexiy , lovro , ivan_metelsky

Problem categories:

Advanced Math, Dynamic Programming