CF330A.Cakeminator

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a rectangular cake, represented as an r × c grid. Each cell either has an evil strawberry, or is empty. For example, a 3 × 4 cake may look as follows:

The cakeminator is going to eat the cake! Each time he eats, he chooses a row or a column that does not contain any evil strawberries and contains at least one cake cell that has not been eaten before, and eats all the cake cells there. He may decide to eat any number of times.

Please output the maximum number of cake cells that the cakeminator can eat.

你被给定一块矩形蛋糕,用一个 r×cr \times c 的网格表示。每个格子要么有一颗邪恶的草莓,要么为空。例如,一块 3×43 \times 4 的蛋糕可能如下所示:

“蛋糕终结者”将要吃掉这块蛋糕!每次他吃蛋糕时,会选择一行或一列,该行或列需满足:

  • 不包含任何邪恶草莓;
  • 至少包含一个尚未被吃过的蛋糕格子。
    然后他将吃掉该行或该列中所有尚未被吃过的蛋糕格子。他可以决定吃任意次数。

请输出蛋糕终结者最多能吃掉的蛋糕格子数量。

输入格式

The first line contains two integers r and c (2 ≤ r, c ≤ 10), denoting the number of rows and the number of columns of the cake. The next r lines each contains c characters — the j-th character of the i-th line denotes the content of the cell at row i and column j, and is either one of these:

  • '.' character denotes a cake cell with no evil strawberry;
  • 'S' character denotes a cake cell with an evil strawberry.

第一行包含两个整数 rr 和 cc(2≤r,c≤102 \leq r, c \leq 10),分别表示蛋糕的行数和列数。接下来的 rr 行,每行包含 cc 个字符——第 ii 行的第 jj 个字符表示第 ii 行第 jj 列单元格的内容,且该字符为以下之一:

  • . 字符表示一个不含邪恶草莓的蛋糕单元格;
  • S 字符表示一个含有邪恶草莓的蛋糕单元格。

输出格式

Output the maximum number of cake cells that the cakeminator can eat.

输出蛋糕切割机最多能吃掉的蛋糕格子数量。

输入输出样例

  • 输入#1

    3 4
    S...
    ....
    ..S.

    输出#1

    8

说明/提示

For the first example, one possible way to eat the maximum number of cake cells is as follows (perform 3 eats).

对于第一个样例,一种能够吃到最多蛋糕格子的方案如下(共执行 3 次“吃”操作)。

输入解题思路,AI测评打分。不知道怎么写?

首页