XY Game

AtCoder
IDarc208_e
Time3000ms
Memory256MB
Difficulty
You are given positive integers $N$, $X$, $Y$ and a length-$N$ integer sequence $A=(A_1,A_2,\ldots,A_N)$. There are $N$ piles of stones, and the $i$\-th pile $(1\le i\le N)$ has $A_i$ stones. Alice and Bob will play the following game using these piles: * Starting with Alice, the two players take turns alternately. * In each turn, the player chooses one non-empty pile and removes one or two stones from that pile. However, the player cannot make a move such that the number of stones in that pile becomes a multiple of $X$ or a multiple of $Y$ after removing stones. The player who cannot make a move first loses. Determine which player wins when both players play optimally. You are given $T$ test cases, solve each of them. ## Constraints * $1\le T \le 2\times 10^5$ * $1\le N \le 2\times 10^5$ * The sum of $N$ over all test cases is at most $2\times 10^5$. * $1\le X < Y\le 10^9$ * $1\le A_i \le 10^{18}$ * All input values are integers. ## Input The input is given from Standard Input in the following format: $T$ $\text{case}_1$ $\text{case}_2$ $\vdots$ $\text{case}_T$ Each test case is given in the following format: $N$ $X$ $Y$ $A_1$ $A_2$ $\ldots$ $A_N$ [samples]
Samples
Input #1
3
2 3 5
4 12
5 1 2
1 2 3 4 5
6 530 879
17031 42909 97721 34323 39597 26999
Output #1
Alice
Bob
Alice

Consider the first test case.
For example, the game proceeds as follows:

*   Alice removes two stones from the first pile. The first pile has two stones remaining.
*   Bob removes one stone from the second pile. The second pile has eleven stones remaining.
*   Alice removes one stone from the first pile. The first pile has one stone remaining.
*   Bob cannot make a move, so Bob loses and Alice wins.

In this test case, Alice always wins no matter how both players make their moves. Therefore, print `Alice` on the first line.
API Response (JSON)
{
  "problem": {
    "name": "XY Game",
    "description": {
      "content": "You are given positive integers $N$, $X$, $Y$ and a length-$N$ integer sequence $A=(A_1,A_2,\\ldots,A_N)$. There are $N$ piles of stones, and the $i$\\-th pile $(1\\le i\\le N)$ has $A_i$ stones. Alice an",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 3000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "arc208_e"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given positive integers $N$, $X$, $Y$ and a length-$N$ integer sequence $A=(A_1,A_2,\\ldots,A_N)$.\nThere are $N$ piles of stones, and the $i$\\-th pile $(1\\le i\\le N)$ has $A_i$ stones.\nAlice an...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments