CF1932A.Thorns and Coins

入门

通过率:0%

时间限制:1.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

During your journey through computer universes, you stumbled upon a very interesting world. It is a path with nn consecutive cells, each of which can either be empty, contain thorns, or a coin. In one move, you can move one or two cells along the path, provided that the destination cell does not contain thorns (and belongs to the path). If you move to the cell with a coin, you pick it up.

Here, green arrows correspond to legal moves, and the red arrow corresponds to an illegal move.

You want to collect as many coins as possible. Find the maximum number of coins you can collect in the discovered world if you start in the leftmost cell of the path.

在穿越计算机宇宙的旅程中,你偶然发现了一个非常有趣的世界。它是一条由 nn 个连续格子组成的路径,每个格子可能为空、含有荆棘,或含有一枚硬币。每次移动,你可以沿路径向前移动一格或两格,前提是目标格子不含有荆棘(且位于路径范围内)。若你移动到含有硬币的格子,你将拾取该硬币。

其中,绿色箭头表示合法移动,红色箭头表示非法移动。

你希望尽可能多地收集硬币。若你从路径最左侧的格子出发,求你在该世界中最多能收集多少枚硬币。

输入格式

The first line of input contains a single integer tt (1≤t≤10001 \le t \le 1000) — the number of test cases. Then the descriptions of the test cases follow.

The first line of each test case contains a single integer nn (1≤n≤501 \le n \le 50) — the length of the path.

The second line of each test case contains a string of nn characters, the description of the path. The character '.' denotes an empty cell, '@' denotes a cell with a coin, and '*' denotes a cell with thorns. It is guaranteed that the first cell is empty.

输入的第一行包含一个整数 tt(1≤t≤10001 \le t \le 1000),表示测试用例的数量。随后是各测试用例的描述。

每个测试用例的第一行包含一个整数 nn(1≤n≤501 \le n \le 50),表示路径的长度。

每个测试用例的第二行包含一个长度为 nn 的字符串,用于描述该路径。字符 '.' 表示空单元格,'@' 表示有硬币的单元格,'*' 表示有荆棘的单元格。保证第一个单元格为空。

输出格式

For each test case, output a single integer, the maximum number of coins you can collect.

对于每个测试用例,输出一个整数,表示你能收集到的硬币的最大数量。

输入输出样例

  • 输入#1

    3
    10
    .@@*@.**@@
    5
    .@@@@
    15
    .@@..@***..@@@*

    输出#1

    3
    4
    3

说明/提示

The picture for the first example is in the problem statement.

Here is the picture for the second example:

And here is the picture for the third example:

第一个示例的图片见题目描述中。

第二个示例的图片如下:

第三个示例的图片如下:

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

首页