QOJ.ac

QOJ

Limite de temps : 0.5 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓

#16942. Лестница для участников олимпиады

Statistiques

在“天狼星”教育中心,各种楼梯是学生们聚集和非正式交流的最爱场所。然而,信息学奥林匹克竞赛的参赛人数大大超过了任何其他教育项目的学生人数,在现有的楼梯中找不到适合他们的楼梯。因此,后勤保障部门决定利用一块特殊的原材料建造一座新楼梯。

原材料是一个由 $h$ 行 and $w$ 列组成的网格,行从上到下编号,列从左到右编号。网格的每个单元格中都写着一个数字—— $0$ 或 $1$。楼梯只能由写有 $1$ 的单元格构成。

建成的楼梯由若干个写有 $1$ 的单元格组成,这些单元格分布在网格的若干连续行中。在楼梯的每一行中,选中的单元格集合必须是一个连续的区间。此外,对于属于楼梯的每一行,其选中的单元格数量必须不小于其正上方那一行(即前一行)选中的单元格数量,且每一行中选中的最左侧单元格必须位于同一列。

下面是一个楼梯的例子。

请在给定的网格中,找出构成楼梯的最大单元格数量。

输入格式

输入的第一行包含两个整数 $h$ 和 $w$ ($1 \le h, w \le 2 \cdot 10^5$, $h \cdot w \le 4 \cdot 10^6$) — 分别表示网格的行数和列数。

接下来的 $h$ 行,每行包含 $w$ 个字符,每个字符为 01 — 表示网格单元格中的数字。

输出格式

输出一个整数 — 构成楼梯的最大单元格数量。

子任务

子任务 分值 限制条件
$h, w$
依赖的子任务
1 25 $h, w \le 50$ 样例
2 25 $h, w \le 400$ 样例, 1
3 25 $h \cdot w \le 200\,000$ 样例, 1, 2
4 25 样例, 1–3

样例

输入格式 1

6 4
0011
1101
0111
1110
0111
0100

输出格式 1

8

说明

下图展示了第一个样例的情况。由最大可能数量的单元格组成的楼梯用灰色标出。

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.