QOJ.ac

QOJ

시간 제한: 1.0 s 메모리 제한: 32 MB 총점: 80

#16405. MISA

통계

罗马天主教弥撒中有一个美好的环节是“互祝平安”仪式,人们会与邻座握手并说“愿平安与你同在”。Mirko 找到了一个让这个仪式对自己有利的方法。

教堂内有 $R$ 排长椅,每排可容纳 $S$ 个人。我们可以将座位安排想象为一个大小为 $R \times S$ 的矩阵,其中每个元素代表一个人或一个空座位。我们假设每个人都会与他们的邻居握手。这意味着邻居位于八个相邻元素之一(如果该元素存在):

在 Mirko 进入之前,教堂内人们的座位安排已经给出。当然,Mirko 在早上的弥撒中迟到了,他将坐在一个空座位上,以便能与尽可能多的人握手。如果没有空座位了,Mirko 就会放弃这个想法,转而参加晚上的弥撒。我们可以假设在 Mirko 之后没有人再进入教堂。

计算早上弥撒期间进行的握手总次数。

输入格式

输入的第一行包含正整数 $R$ 和 $S$($1 \le R, S \le 50$),含义如题面所述。

接下来的 $R$ 行,每行包含 $S$ 个字符。这 $R \times S$ 个字符代表座位安排。字符 .(点)代表空位,字符 o(小写字母 o)代表一个人。

输出格式

输出的第一行也是唯一一行,应包含所需的握手总次数。

子任务

  • 在占总分 20% 的测试数据中,$R = 1$。
  • 在占总分 20% 的测试数据中,$R = 2$。
  • 在占总分 20% 的测试数据中,教堂将是满的,这意味着所有座位都被占用了。

样例

输入 1

2 3
..o
o..

输出 1

2

输入 2

2 2
oo
oo

输出 2

6

说明

第一个样例的解释:

Mirko 将选择一个座位坐下,使他能与两个人握手,这给我们提供了两种可能性:

.oo
o..

..o
oo

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.