#P3718. [AHOI2017初中组] alter
[AHOI2017初中组] alter
Description
There are lamps in a row. Some lamps are on, and some are off. Keke wants the lamps to be alternating. He defines the ugliness of a row of lamps as the number of lamps in the longest consecutive segment that are all on or all off. Keke can press switches at most times. Each operation toggles the state of one lamp: if it was on, it becomes off; otherwise, it becomes on. Given the current states of the lamps, find the minimal ugliness after the operations.
Input Format
The first line contains two integers .
The second line is a string of length consisting of two characters: N and F. Here, N means the lamp is on, and F means the lamp is off.
Output Format
Output the minimal ugliness.
8 1
NNNFFNNN
3
Hint
of the testdata: .
of the testdata: .
Another of the testdata: , and the string is all N or all F.
of the testdata: .
This problem includes hack testdata.
Translated by ChatGPT 5
京公网安备 11011102002149号