#abc229d. D - Longest X
D - Longest X
Score : points
问题描述
给定一个由 X 和 . 组成的字符串 。
你可以在 到 次(包括)之间对 执行以下操作:
- 将一个
.替换为X。
在执行完操作后, 中可能出现的最大连续 X 数量是多少?
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Given is a string consisting of X and ..
You can do the following operation on between and times (inclusive).
- Replace a
.with anX.
What is the maximum possible number of consecutive Xs in after the operations?
Constraints
- Each character of is
Xor.. - is an integer.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
XX...X.X.X.
2
Sample Output 1
5
After replacing the Xs at the -th and -th positions with X, we have XX...XXXXX., which has five consecutive Xs at -th through -th positions.
We cannot have six or more consecutive Xs, so the answer is .
Sample Input 2
XXXX
200000
Sample Output 2
4
It is allowed to do zero operations.
update @ 2024/3/10 10:01:15