#P3590. [POI 2015 R2] 三座塔 Three towers
[POI 2015 R2] 三座塔 Three towers
Description
Given a string of length containing only the characters , , and , find the longest contiguous substring such that it either contains only one kind of character, or it contains multiple kinds of characters but no two characters occur the same number of times.
Input Format
The first line contains a positive integer (), the length of the string. The second line contains a string of length .
Output Format
Output a single positive integer: the length of the longest substring that satisfies the condition.
9
CBBSSBCSC
6
Hint
Sample Explanation
Choose the substring .
Original title: Trzy wieże.
Translated by ChatGPT 5
京公网安备 11011102002149号