codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1921E.md (3044B)


      1 Source: https://codeforces.com/problemset/problem/1921/E
      2 
      3 E. Eat the Chip
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Alice and Bob are playing a game on a checkered board. The board has $h$ rows, numbered from top to bottom, and $w$ columns, numbered from left to right. Both players have a chip each. Initially, Alice's chip is located at the cell with coordinates $(x_a, y_a)$ (row $x_a$, column $y_a$), and Bob's chip is located at $(x_b, y_b)$. It is guaranteed that the initial positions of the chips do not coincide. Players take turns making moves, with Alice starting.
     22 
     23 On her turn, Alice can move her chip one cell down or one cell down-right or down-left (diagonally). Bob, on the other hand, moves his chip one cell up, up-right, or up-left. It is not allowed to make moves that go beyond the board boundaries.
     24 
     25 More formally, if at the beginning of Alice's turn she is in the cell with coordinates $(x_a, y_a)$, then she can move her chip to one of the cells $(x_a + 1, y_a)$, $(x_a + 1, y_a - 1)$, or $(x_a + 1, y_a + 1)$. Bob, on his turn, from the cell $(x_b, y_b)$ can move to $(x_b - 1, y_b)$, $(x_b - 1, y_b - 1)$, or $(x_b - 1, y_b + 1)$. The new chip coordinates $(x', y')$ must satisfy the conditions $1 \le x' \le h$ and $1 \le y' \le w$.
     26 
     27  ![](https://espresso.codeforces.com/d84e97b980ff74c5bb717a3d34d4c05a4b10e64a.png) Example game state. Alice plays with the white chip, Bob with the black one. Arrows indicate possible moves. 
     28 
     29 A player immediately wins if they place their chip in a cell occupied by the other player's chip. If either player cannot make a move (Alice—if she is in the last row, i.e. $x_a = h$, Bob—if he is in the first row, i.e. $x_b = 1$), the game immediately ends in a draw.
     30 
     31 What will be the outcome of the game if both opponents play optimally?
     32 
     33 Input
     34 
     35 Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \le t \le 10^4$) — the number of test cases. This is followed by the description of the test cases.
     36 
     37 Each test case consists of a single line containing six integers $h$, $w$, $x_a$, $y_a$, $x_b$, $y_b$ ($1 \le x_a, x_b \le h \le 10^6$, $1 \le y_a, y_b \le w \le 10^9$) — the dimensions of the board and the initial positions of Alice's and Bob's chips. It is guaranteed that either $x_a \ne x_b$ or $y_a \ne y_b$.
     38 
     39 It is guaranteed that the sum of $h$ over all test cases does not exceed $10^6$.
     40 
     41 Output
     42 
     43 For each test case, output "Alice" if Alice wins, "Bob" if Bob wins, and "Draw" if neither player can secure a victory. You can output each letter in any case (lowercase or uppercase). For example, the strings "bOb", "bob", "Bob", and "BOB" will be accepted as Bob's victory.
     44 
     45 Example
     46 
     47 Input
     48 
     49 ```
     50 12
     51 
     52 6 5 2 2 5 3
     53 
     54 4 1 2 1 4 1
     55 
     56 1 4 1 3 1 1
     57 
     58 5 5 1 4 5 2
     59 
     60 4 4 1 1 4 4
     61 
     62 10 10 1 6 10 8
     63 
     64 10 10 2 6 10 7
     65 
     66 10 10 9 1 8 1
     67 
     68 10 10 8 1 10 2
     69 
     70 10 10 1 1 2 1
     71 
     72 10 10 1 3 4 1
     73 
     74 10 10 3 1 1 1
     75 ```
     76 
     77 Output
     78 
     79 ```
     80 Alice
     81 Bob
     82 Draw
     83 Draw
     84 Draw
     85 Alice
     86 Draw
     87 Draw
     88 Bob
     89 Alice
     90 Alice
     91 Draw
     92 ```