QOJ.ac

QOJ

시간 제한: 1.0 s 메모리 제한: 256 MB 총점: 100

#15645. 停车派对

통계

Peyman 决定在他在扎博勒(Zabol)的家中举办一场晚宴。他的房子有一个矩形停车场,可以用一个 $n$ 行 $m$ 列的网格来表示。一辆车可以停在这个网格的 $n \times m$ 个单元格之一中。然而,一些单元格被无法移动的柱子占据,因此任何车辆都不能停在这些单元格中,也不能穿过它们。

停车场中的每一行和每一列在其两端各有一个入口。当一辆车通过某个入口进入停车场时,它只能在对应的行或列中沿直线向前行驶;当它到达对面的入口,或者下一个单元格被柱子或其他已停放的车辆占据时,它就会停止并停在该单元格中。此外,如果某行或某列的第一个单元格(即入口处的单元格)已被占据,则车辆无法从该入口进入。

Peyman 希望最大化可以停放在他的停车场中的车辆数量。为了实现这一目标,他可以在宾客到达时指示他们选择哪一个入口进入。你的任务是帮助 Peyman 完成这个任务。

输入格式

输入的第一行包含两个空格分隔的整数 $n$ 和 $m$($1 \le n, m \le 1000$),分别表示停车场的行数和列数。

接下来的 $n$ 行,每行包含一个长度为 $m$ 且仅由 .o 组成的字符串。第 $i$ 行的第 $j$ 个字符如果为 o,表示第 $i$ 行第 $j$ 列的单元格中有一个柱子;如果为 .,则表示该单元格为空。

输出格式

输出一个整数 $k$,表示 Peyman 可以在他的停车场中停放的最大车辆数量。

样例

输入样例 1

3 3
.o.
o.o
.o.

输出样例 1

4

输入样例 2

3 4
oooo
....
...o

输出样例 2

7

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.