QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 68 MB مجموع النقاط: 100 قابلة للهجوم ✓

#2489. 皇帝的宫殿

الإحصائيات

伟大的 Emelyan I 皇帝正在为自己建造一座宫殿。为了彰显皇帝的伟大,宫殿必须非常宏大——它必须从太空中可见。此外,宫殿的形状必须是字母 E。

更正式地说,宫殿应该是四个矩形的并集:一个大小为 $a \times 1$ 的主楼,以及三个大小为 $1 \times b$ 的侧翼,它们从东侧与主楼相邻,其中 $a$ 和 $b$ 是正整数且 $a \ge 5$。北侧翼应与主楼的右上角相邻,南侧翼应与主楼的右下角相邻。中间的侧翼不应与北侧翼或南侧翼相邻,但其左上角应与主楼相邻,且距离主楼右上角的距离为整数。

换句话说,宫殿必须完全占据某个大小为 $a \times (b + 1)$ 的矩形中的所有 $1 \times 1$ 方格:即该矩形左侧、上侧或下侧相邻的所有方格,加上矩形内部的一条不与顶边和底边相邻的线。

宫殿的总面积为 $a + 3b$。

未来宫殿的建设区域是一个大小为 $h \times w$ 的矩形,被划分为 $1 \times 1$ 的单元格。一些单元格被皇帝的花园占据,不能在其上建造。其余单元格为空闲,可以在其上建造。

确定可以在空闲空间上建造的宫殿的最大面积。

输入格式

第一行包含两个整数 $h$ 和 $w$ ($5 \le h, w \le 10^6$, $h \times w \le 5 \times 10^6$)。

接下来的 $h$ 行,每行包含 $w$ 个字符。第 $i$ 行的第 $j$ 个字符,如果坐标为 $(i, j)$ 的单元格被占用,则为“#”,如果该单元格为空闲,则为“.”。

输出格式

输出一个整数——宫殿可能的最大面积。如果无法建造宫殿,则输出“-1”。

样例

样例输入 1

6 6
#.....
....#.
..####
....##
..##..
......

样例输出 1

14

样例输入 2

6 6
#.....
...##.
..####
....##
..##..
......

样例输出 2

12

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.