시간 제한 | 메모리 제한 | 제출 | 정답 | 맞은 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 128 MB | 35 | 18 | 15 | 48.387% |
A squared word is a word of the form xx, i.e., consisting of a sequence of letters repeated twice. Some examples of squared words in English are the words: couscous, murmur (= a low, continuous sound), tartar (= hardened dental plaque) and hotshots. We would like to find out, for a given word, how many letters should be removed from the word for it to become a squared word (however, not necessarily a correct English word).
The first line of the standard input contains an integer n (1 ≤ n ≤ 1000), denoting the length of the word. The second line contains a word consisting of n lower case English letters.
The first and only line of the standard output should contain a single integer - the minimal number of letters that should be removed from the word for it to become a squared word. We assume that the empty word is a correct squared word.
15 tachystoskopach
7
If we remove the letters y
, s
, o
, s
, k
, o
and p
, we obtain a squared word tachtach
. In Polish, this word represents a (not really well known) kind of a coach.
Contest > Algorithmic Engagements > PA 2010 3-2번