302057: CF391B. Word Folding

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Word Folding

题目描述

You will receive 5 points for solving this problem. Manao has invented a new operation on strings that is called folding. Each fold happens between a pair of consecutive letters and places the second part of the string above first part, running in the opposite direction and aligned to the position of the fold. Using this operation, Manao converts the string into a structure that has one more level than there were fold operations performed. See the following examples for clarity. We will denote the positions of folds with '|' characters. For example, the word "ABRACADABRA" written as "AB|RACA|DAB|RA" indicates that it has been folded three times: first, between the leftmost pair of 'B' and 'R' letters; second, between 'A' and 'D'; and third, between the rightmost pair of 'B' and 'R' letters. Here are several examples of folded strings: `<br></br>"ABCDEF|GHIJK" | "A|BCDEFGHIJK" | "AB|RACA|DAB|RA" | "X|XXXXX|X|X|XXXXXX"<br></br> | | | XXXXXX<br></br> KJIHG | KJIHGFEDCB | AR | X<br></br> ABCDEF | A | DAB | X<br></br> | | ACAR | XXXXX<br></br> | | AB | X<br></br>`One last example for "ABCD|EFGH|IJ|K": `<br></br> K<br></br>IJ<br></br>HGFE<br></br>ABCD<br></br>`Manao noticed that each folded string can be viewed as several piles of letters. For instance, in the previous example, there are four piles, which can be read as "AHI", "BGJK", "CF", and "DE" from bottom to top. Manao wonders what is the highest pile of identical letters he can build using fold operations on a given word. Note that the pile should not contain gaps and should start at the bottom level. For example, in the rightmost of the four examples above, none of the piles would be considered valid since each of them has gaps, starts above the bottom level, or both.

输入输出格式

输入格式


The input will consist of one line containing a single string of $ n $ characters with $ 1<=n<=1000 $ and no spaces. All characters of the string will be uppercase letters. This problem doesn't have subproblems. You will get 5 points for the correct submission.

输出格式


Print a single integer — the size of the largest pile composed of identical characters that can be seen in a valid result of folding operations on the given string.

输入输出样例

输入样例 #1

ABRACADABRA

输出样例 #1

3

输入样例 #2

ABBBCBDB

输出样例 #2

3

输入样例 #3

AB

输出样例 #3

1

说明

Consider the first example. Manao can create a pile of three 'A's using the folding "AB|RACAD|ABRA", which results in the following structure: `<br></br>ABRA<br></br>DACAR<br></br> AB<br></br>`In the second example, Manao can create a pile of three 'B's using the following folding: "AB|BB|CBDB". `<br></br>CBDB<br></br>BB<br></br>AB<br></br>`Another way for Manao to create a pile of three 'B's with "ABBBCBDB" is the following folding: "AB|B|BCBDB". `<br></br> BCBDB<br></br> B<br></br>AB<br></br>`In the third example, there are no folds performed and the string is just written in one line.

Input

Source/Category

加入题单

算法标签: