Solutions are presented as using the least memory and the fastest execution time. It also takes the top
10 most recent solutions from each language. If you want to limit to a specific index, click the
"Solved" button and go to that problem.
Problems
B'You are given a text consisting of n space-separated words. There is exactly one space character between any pair of adjacent words. There are no spaces before the first word and no spaces after the last word. The length of text is the number of letters and spaces in it. w_i is the i -th word of text. All words consist only of lowercase Latin letters. Let 's denote a segment of words w[i..j] as a sequence of words w_i, w_{i + 1}, ... , w_j . Two segments of words w[i_1 .. j_1] and w[i_2 .. j_2] are considered equal if j_1 - i_1 = j_2 - i_2 , j_1 ge i_1 , j_2 ge i_2 , and for every t in [0, j_1 - i_1] w_{i_1 + t} = w_{i_2 + t} . For example, for the text "to be or not to be" the segments w[1..2] and w[5..6] are equal, they correspond to the words "to be". An abbreviation is a replacement of some segments of words with their first uppercase letters. In order to perform an abbreviation, you have to choose at least two non-intersecting equal segments of words, and replace each chosen segment with the string consisting of first letters of the words in the segment (written in uppercase). For example, for the text "a ab a a b ab a a b c" you can replace segments of words w[2..4] and w[6..8] with an abbreviation "AAA" and obtain the text "a AAA b AAA b c", or you can replace segments of words w[2..5] and w[6..9] with an abbreviation "AAAB" and obtain the text "a AAAB AAAB c". What is the minimum length of the text after at most one abbreviation? The first line of the input contains one integer n ( 1 <= n <= 300 ) -- the number of words in the text. The next line contains n space-separated words of the text w_1, w_2, ... , w_n . Each word consists only of lowercase Latin letters. It is guaranteed that the length of text does not exceed 10^5 . Print one integer -- the minimum length of the text after at most one abbreviation. In the'... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
39922839 |
cjy2003 |
F |
July 3, 2018, 4:13 p.m. |
OK |
GNU C++ |
TESTS |
85 |
577 |
30310400 |
|
2400 |
39926802 |
lzqaq |
F |
July 3, 2018, 4:31 p.m. |
OK |
GNU C++11 |
TESTS |
85 |
374 |
25190400 |
|
2400 |
39925614 |
mohammadrobot |
F |
July 3, 2018, 4:26 p.m. |
OK |
GNU C++14 |
TESTS |
85 |
46 |
512000 |
|
2400 |
39923876 |
JanchoMath |
F |
July 3, 2018, 4:18 p.m. |
OK |
GNU C++14 |
TESTS |
85 |
46 |
512000 |
|
2400 |
39923720 |
CrownJJ |
F |
July 3, 2018, 4:17 p.m. |
OK |
GNU C++14 |
TESTS |
85 |
46 |
614400 |
|
2400 |
39912717 |
peanutpedo20 |
F |
July 3, 2018, 3:30 p.m. |
OK |
GNU C++14 |
TESTS |
85 |
46 |
716800 |
|
2400 |
39919506 |
Mr.HP |
F |
July 3, 2018, 3:58 p.m. |
OK |
GNU C++14 |
TESTS |
85 |
46 |
58982400 |
|
2400 |
39918683 |
gXa |
F |
July 3, 2018, 3:54 p.m. |
OK |
GNU C++14 |
TESTS |
85 |
62 |
512000 |
|
2400 |
39925104 |
Kennenn |
F |
July 3, 2018, 4:23 p.m. |
OK |
GNU C++14 |
TESTS |
85 |
187 |
307200 |
|
2400 |
39927005 |
Cueball1234 |
F |
July 3, 2018, 4:32 p.m. |
OK |
GNU C++14 |
TESTS |
85 |
187 |
24064000 |
|
2400 |
remove filters
Back to search problems