mod M Game

AtCoder
IDarc148_d
Time2000ms
Memory256MB
Difficulty
There are $2N$ integers $A_1, A_2, ..., A_{2N}$ written on a blackboard, and an integer $M$ at least $2$. Alice and Bob will play a game. They will alternately perform the following operation, with Alice going first, until there is no number on the blackboard. * Choose a number and delete it from the blackboard. At the end of the game, if the sum of numbers deleted by Alice modulo $M$ equals the sum of numbers deleted by Bob modulo $M$, Bob wins; otherwise, Alice wins. Which player will win if both plays optimally? ## Constraints * $1 \leq N \leq 2 \times 10^5$ * $2 \leq M \leq 10^9$ * $0 \leq A_i \leq M - 1$ * All values in the input are integers. ## Input The input is given from Standard Input in the following format: $N$ $M$ $A_1$ $A_2$ $\dots$ $A_{2N}$ [samples]
Samples
Input #1
2 9
1 4 8 5
Output #1
Alice

The game may proceed as follows.

*   Alice deletes $1$.
*   Bob deletes $4$.
*   Alice deletes $5$.
*   Bob deletes $8$.

In this case, the sum of numbers deleted by Alice modulo $M$ is $(1 + 5) \bmod 9 = 6$, and the sum of numbers deleted by Bob modulo $M$ is $(4 + 8) \bmod 9 = 3$. Since $6 \neq 3$, Alice wins.
Input #2
3 998244353
1 2 3 1 2 3
Output #2
Bob
API Response (JSON)
{
  "problem": {
    "name": "mod M Game",
    "description": {
      "content": "There are $2N$ integers $A_1, A_2, ..., A_{2N}$ written on a blackboard, and an integer $M$ at least $2$.   Alice and Bob will play a game. They will alternately perform the following operation, with ",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "arc148_d"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "There are $2N$ integers $A_1, A_2, ..., A_{2N}$ written on a blackboard, and an integer $M$ at least $2$.  \nAlice and Bob will play a game. They will alternately perform the following operation, with ...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments