atcoder#ABC229G. [ABC229G] Longest Y
[ABC229G] Longest Y
Score : points
Problem Statement
Given is a string consisting of Y
and .
.
You can do the following operation on between and times (inclusive).
- Swap two adjacent characters in .
What is the maximum possible number of consecutive Y
s in after the operations?
Constraints
- Each character of is
Y
or.
. - is an integer.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
YY...Y.Y.Y.
2
3
After swapping the -th, -th characters, and -th, -th characters, we have YY....YYY..
, which has three consecutive Y
s at -th through -th positions.
We cannot have four or more consecutive Y
s, so the answer is .
YYYY....YYY
3
4