Destruction of Walls

AtCoder
IDarc203_c
Time2000ms
Memory256MB
Difficulty
Rooms are arranged in a grid with $H$ rows and $W$ columns. There are walls between adjacent rooms that share an edge. When you are in room $A$ and room $B$ is adjacent to room $A$ in one of the four directions **(up, down, left, right)**, and the wall between room $A$ and room $B$ has been demolished, you can move from room $A$ to room $B$. Find the total number, modulo $998244353$, of ways to choose $K$ walls such that the following condition is satisfied. * When all chosen walls are demolished, it is possible to move from the top-left room to the bottom-right room by passing through some rooms. Solve $T$ test cases for each input file. ## Constraints * $1 \leq T \leq 2 \times 10^5$ * $2 \leq H \leq 2 \times 10^5$ * $2 \leq W \leq 2 \times 10^5$ * $\boldsymbol{0 \leq K \leq H+W}$ * All input values are integers. ## Input The input is given from Standard Input in the following format: $T$ $case_1$ $case_2$ $\vdots$ $case_T$ Each case is given in the following format: $H$ $W$ $K$ [samples]
Samples
Input #1
6
2 2 1
2 2 3
2 2 2
2 2 4
200000 200000 400000
2 203 203
Output #1
0
4
2
1
387815582
203

In the first case, demolishing any single wall does not allow movement from the top-left room to the bottom-right room.  
In the second case, choosing and demolishing any three walls out of the four available walls allows movement from the top-left room to the bottom-right room.
API Response (JSON)
{
  "problem": {
    "name": "Destruction of Walls",
    "description": {
      "content": "Rooms are arranged in a grid with $H$ rows and $W$ columns. There are walls between adjacent rooms that share an edge.   When you are in room $A$ and room $B$ is adjacent to room $A$ in one of the fou",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "arc203_c"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Rooms are arranged in a grid with $H$ rows and $W$ columns. There are walls between adjacent rooms that share an edge.  \nWhen you are in room $A$ and room $B$ is adjacent to room $A$ in one of the fou...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments