#P7589. Alice and Bob's Black-White Chess Game

    ID: 20783 Type: Default 1000ms 256MiB

Alice and Bob's Black-White Chess Game

Alice and Bob's Black-White Chess Game

Alice and Bob are playing a game called "Black‐White Chess". The game is played on a Cartesian plane with the following rules:

  • The game is played on a set of horizontal lines (parallel to the X-axis).
  • Alice has black pieces and Bob has white pieces. Initially, for each of the n chosen horizontal lines (each with a distinct integer Y-intercept), Alice places one black piece and Bob places one white piece. On each line the pieces are placed at distinct integer X-coordinates.
  • The players take turns; Alice moves first. On a turn, a player must choose one of the lines and move the piece of his/her own color on that line.
  • There are two types of moves:
    • Forward move: The chosen piece is moved toward the opponent's piece by any positive integer number of steps, as long as it does not jump over or land on the opponent’s piece. Formally, if the distance between the two pieces is |xwhite - xblack|, the number of forward steps allowed is any integer from 1 up to |xwhite - xblack| - 1.
    • Retreat move: The chosen piece can also be moved away from the opponent’s piece by any integer number of steps between 1 and d (inclusive). However, to avoid endless retreats, each player can make at most k retreat moves throughout the game.
  • On his/her turn, if a player has at least one legal move (on any line) he or she must make a move (either forward or retreat, if available under the constraints).
  • If a player cannot make any legal move on any line on his/her turn, that player loses and the game ends.

For convenience, on each line we define the gap as
\( g = |x_{white} - x_{black}| - 1 \).
A forward move on a line decreases the gap from \(g\) to any \(g'\) with \(0 \le g' \le g-1\), while a retreat move increases the gap to \(g + r\) for some \(1 \le r \le d\) (using one available retreat move).

Given the initial configuration of the game, determine whether Alice can force a win assuming both players play optimally.

inputFormat

The input begins with a line containing three integers n, k, and d:

  1. n (number of lines)
  2. k (maximum number of retreat moves allowed per player)
  3. d (maximum distance per retreat move)

Then, there are n lines. Each line contains two integers representing the X-coordinates of the black piece (Alice) and the white piece (Bob) on that horizontal line. Note that the two coordinates in a line are distinct. The gap for that line is defined as \( |x_{white} - x_{black}| - 1 \).

outputFormat

Output a single line containing Alice if Alice can force a win under optimal play, or Bob otherwise.

sample

1 0 1
1 2
Bob