当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6416:Rikka with Seam

题目描述
Seam carving is a novel algorithm for resizing images while maintaining as much information as possible from the source image.

Now, Rikka is going to use seam carving method to deal with an $n \times m$ black and white picture. We can abstract this picture into an $n \times m$ 01 matrix $A$.

A $K$-seam of this picture is an integer sequence $a$ which satisfies the following conditions:
1. $|a| = n$, $a_i \in [1, m]$.
2. $|a_i - a_{i+1}| \leq K$, $\forall i \in [1,n)$.

After choosing a $K$-seam $a$, Rikka reduces the size of the picture by deleting pixels $(i,a_i)$, and then she gets a matrix $A'$ of size $n \times (m - 1)$.

For example, if the chosen seam is $[1,2,3]$ and the picture is \begin{align*} \begin{bmatrix} 1 &0 &0 \\ 1& 1& 1 \\ 0 & 0& 0\end{bmatrix}\end{align*} the result matrix will be \begin{align*} \begin{bmatrix} 0 &0 \\ 1& 1 \\ 0 & 0\end{bmatrix}\end{align*}

Rikka finds that deleting different seams may get the same result. In the previous example, seam $[1,2,3],[1,2,1],[1,2,2],[1,1,1]$ are equivalent.

Now Rikka wants to calculate the number of different matrixes she can get by deleting exactly one $K$-seam.
输入解释
The first line contains a single integer $t(1 \leq t \leq 10^3)$, the numebr of testcases.

For each testcase, the first line contains three numbers $n,m,K(2 \leq n,m \leq 2 \times 10^3, 1\leq K \leq m)$.

Then $n$ lines follow, each line contains a 01 string of length $m$ which describes one row of the matrix.

The input guarantees that there are at most $5$ testcases with $\max (n,m) > 300$.
输出解释
For each testcase, output a single line with a single number, the answer modulo $998244353$.
输入样例
3
2 2 1
00
10
5 5 1
00100
10101
00100
01000
11101
5 5 2
00100
10101
00100
01000
11101
输出样例
2
70
199
来自杭电HDUOJ的附加信息
Recommend chendu

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6416

最后修改于 2020-10-25T23:31:08+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
16000/8000MS(Java/Others) 524288/524288K(Java/Others)