QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 262144 MB Total points: 100 Hackable ✓

#13213. 黑白正方形

Statistics

受到之前画作成功的鼓舞,卡齐米尔·马列维奇(Kazimir Malevich)准备创作一幅新的杰作。为了达到全新的抽象水平,他决定将创作过程分为几个步骤。

他首先拿出一块白色画布,将其划分为 $n \times m$ 个相同的正方形网格单元。之后,他将其中一些单元格涂成了黑色。现在,马列维奇想要沿着网格线剪裁出一个正方形区域,并希望它是“条纹状”的。当代艺术家对条纹区域的定义如下:它恰好包含 $k$ 个不同的黑色行,恰好包含 $k$ 个不同的黑色列,且所有其他单元格均为白色。现在,马列维奇被以下问题难住了:“有多少种不同的方式可以找到一个条纹正方形?”请帮他计算在画布上可以找到多少个不同的条纹正方形区域。如果两个正方形区域的边长不同,或者左上角坐标不同,则认为它们是不同的。

输入格式

第一行包含整数 $n, m$ 和 $k$ ($1 \le n, m, k \le 1000$)。接下来 $n$ 行描述了画布。每行包含 $m$ 个字符,每个字符要么是 '1',要么是 '0'。'0' 表示画布上对应的单元格是白色的,'1' 表示它是黑色的。

输出格式

单行输出问题的答案。

样例

输入 1

5 6 2
010100
111111
010100
111111
010100

输出 1

7

说明

我们将一个正方形区域表示为 $(R, C, L)$,其中 $R$ 和 $C$ 表示左上角的行号和列号,$L$ 表示其边长。在给定的示例中,有七种不同的方式来选择条纹正方形区域:$(2, 2, 3), (1, 1, 4), (1, 2, 4), (2, 1, 4), (2, 2, 4), (1, 1, 5), (1, 2, 5)$。

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.