No.2932 Eh, eh, no way no way no way, wait wait wait??? Huh, seriously? For real? This is seriously way too crazy, you know? Eh, oh, is it really okay to do this much DP??? This is seriously way too crazy, you know???
タグ : / 解いたユーザー数 50
作問者 :
tnodino
/ テスター :
mymelochan
kusirakusira
Problem Statement
There is a grid $A$ with $H$ rows and $W$ columns. The cell in the $i$-th row from the top and the $j$-th column from the left contains an integer $A_{(i, j)}$.
Let the function $f(A)$ be the answer to the following problem.
You start at cell $(1, 1)$, and repeatedly move from your current cell to the adjacent cell on the right $(i, j+1)$ or the adjacent cell below $(i+1, j)$.
However, you cannot make a move that goes outside the grid.
Furthermore, letting $x$ be the value written in the current cell and $y$ be the value written in the destination cell, $x \lt y$ must hold.
How many ways are there to move to cell $(H, W)$?
Here, $2$ ways of moving $(P_1 \dots P_N)$ and $(Q_1 \dots Q_M)$ are considered different if $N \neq M$, or if there exists at least $1$ index $i$ such that $P_i \neq Q_i$.
($P_i, Q_i$ denote a move to the right or down.)
There are $M^{HW}$ grids with $H$ rows and $W$ columns in which each cell contains an integer satisfying $1 \le A_{(i, j)} \le M$.
Output the sum of the values of $f(A)$ over all these grids, modulo $998244353$.
Constraints
- $2 \le H, W \le 2,000$
- $1 \le M \le 10^9$
- All inputs are integers
Input
$H\ W\ M$
Output
Output the answer.
Sample
Sample 1
Input
2 2 3
Output
6
There are 4 grids with $f(A) = 1$.
12 12 11 13
13 33 23 23
There is 1 grid with $f(A) = 2$.
12
23
All other grids have $f(A) = 0$.
The sum of $f(A)$ over all grids is 6.
Sample 2
Input
2 2 2
Output
0
In no grid is it possible to move to $(H, W)$.
Sample 3
Input
1000 1000 100000
Output
866431467
Output the answer modulo $998244353$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。