QOJ.ac

QOJ

시간 제한: 1 s 메모리 제한: 128 MB 총점: 100

#13962. 布料

통계

乌鸦 Kraw 有一块美丽的布料。布料上的图案非常复杂,以至于布料的每个部分都是独一无二的。然而,在 2017 年的大火之后,布料上现在留下了许多难看的洞。(当然,这场大火是由老鼠 Squeaky 引起的。)

Kraw 想要忘记这场大火,因为他不太喜欢热。他想从布料中剪下一个矩形,然后把其余的部分扔掉。新剪下的布料面积必须至少为 $K$,且不能包含任何洞。

由于 Kraw 的布料具有规范反对称性质(或者类似的性质——Kraw 记不清售货员是怎么说的了),Kraw 只能沿着规则的网格线剪裁布料。Kraw 想知道,有多少种不同的方法可以从布料中剪出一个面积至少为 $K$ 且不包含任何洞的矩形?

输入格式

输入从标准输入读取。输入包含以下内容:

  • 第一行包含三个整数 $N$、$M$($1 \le N, M \le 2\,000$)和 $K$($1 \le K \le MN$),分别表示布料的高度和宽度,以及矩形必须包含的最小网格单元数量(即最小面积);
  • 接下来的 $N$ 行,每行包含 $M$ 个整数 $s_{0y}, s_{1y}, \dots, s_{(M-1)y}$。如果坐标为 $(x, y)$ 的网格单元上有洞,则 $s_{xy}$ 为 1;如果没有洞,则为 0。

输出格式

输出一行,包含一个整数:表示从布料中剪出面积至少为 $K$ 且不包含任何洞的矩形的方案数。

样例

输入 1

2 4 3
1 0 0 0
0 0 0 1

输出 1

3

说明

可以从布料中剪出 3 个面积至少为 3 的矩形。若将左上角的网格单元视为 $(0, 0)$,则有:

  • 2 个面积为 3 的矩形:$\{(1, 0), (2, 0), (3, 0)\}$,$\{(0, 1), (1, 1), (2, 1)\}$
  • 1 个面积为 4 的矩形:$\{(1, 0), (2, 0), (1, 1), (2, 1)\}$

子任务

每个测试点的最大运行时间为 1.0 秒。

您的程序将在以下测试点集合上进行测试:

子任务 分值 限制条件
1 7 每个测试点满足 $0 < N, M \le 2000$,$K = 1$,且对于所有 $(x, y)$ 均有 $s_{xy} = 0$;
2 9 每个测试点满足 $0 < N, M \le 2000$,$K = 1$,且仅有一个 $(x, y)$ 满足 $s_{xy} = 1$;
3 12 每个测试点满足 $0 < N, M \le 50$;
4 14 每个测试点满足 $0 < N, M \le 500$;
5 23 每个测试点满足 $0 < N, M \le 2000$ 且 $K = 1$;
6 35 每个测试点满足 $0 < N, M \le 2000$。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.