CF2244A.Iskander and Drawings
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
During a geometry lesson, Iskander got very bored, so he decided to draw in Yura's notebook. To do this, he took a row and drew horizontal lines on it. Some lines are long, some are short, and some parts of the page remain empty.
The page is represented by a string s, where the character '*' denotes an empty part of the paper, and the character '#' denotes one centimeter of a drawn line. A continuous sequence of '#' characters forms a single line.
Yura decided to erase all the lines and made Iskander help him: they will erase one of the lines from both ends simultaneously.
- Each second, Iskander erases 1 centimeter from the right end of the line, and Yura erases 1 centimeter from the left end.
- If the current length of the line is 1 or 2 centimeters, then in the next second it is erased completely, and the process ends.
Yura wants to choose a line so that, together with Iskander, they erase it for as long as possible. Help him determine this maximum time. If there are no lines on the page, the answer is 0 seconds.
在几何课上,伊斯坎德尔感到非常无聊,于是决定在尤拉的笔记本上涂画。为此,他选取了一行,并在该行上画了一些水平线段。有些线段较长,有些较短,而页面的某些部分则保持空白。
页面用一个字符串 s 表示,其中字符 '*' 表示纸张的空白部分,字符 '#' 表示已绘制的一厘米线段。连续的一串 '#' 字符构成一条单独的线段。
尤拉决定擦掉所有线段,并让伊斯坎德尔协助他:他们将同时从某一条线段的两端开始擦除。
- 每秒,伊斯坎德尔从该线段的右端擦除 1 厘米,尤拉从该线段的左端擦除 1 厘米。
- 如果当前线段长度为 1 或 2 厘米,则下一秒该线段将被完全擦除,过程结束。
尤拉希望选择一条线段,使得他和伊斯坎德尔共同擦除该线段所用的时间尽可能长。请帮助他确定这一最大时间。若页面上没有线段,则答案为 0 秒。
输入格式
The first line contains a single integer t (1≤t≤2500) — the number of test cases.
The first line of each test case contains an integer n (1≤n≤10) — the length of the string s.
The second line of each test case contains a string s of length n, consisting of characters '#' and '*'.
第一行包含一个整数 t(1≤t≤2500)——测试用例的数量。
每个测试用例的第一行包含一个整数 n(1≤n≤10)——字符串 s 的长度。
每个测试用例的第二行包含一个长度为 n 的字符串 s,由字符 '#' 和 '*' 组成。
输出格式
For each test case, output a single integer — the maximum time required to erase a line.
对于每个测试用例,输出一个整数——擦除一行所需的最大时间。
输入输出样例
输入#1
5 7 #*##*## 8 ######## 8 ******** 8 #*****## 6 *#####
输出#1
1 4 0 1 3
说明/提示
null
输入解题思路,AI测评打分。不知道怎么写?