Time Limit : 5 Second
Memory Limit : 128 MB
Submission: 45
Solved: 9
Description
Elenore has a list of strings that she wants to put in a file. She could just put them all into a file in order, but she wants to minimize the size of the file. So she figures she can combine all the strings into one large string which contains the original strings as substrings. Then for each string she just needs to store the index and length of the string.
For example, let's say the strings she needs to store are:
• doghouse
• houseboat
• corndog
Then Elenore can make the string "corndoghouseboat" that contains all the input strings.
Input
There will be several test cases.
Each test case will start with a line with a positive integer, N, that is at most 20. Then N lines will follow each containing a string. The strings will consist of only lowercase letters.
Output
For each test case, output a line that says "Elenore can use a string of length L." where L is the length of the shortest string that contains all of the input strings.
sample input
3
doghouse
houseboat
corndog
1
hello
4
department
of
redundancy
department
sample output
Elenore can use a string of length 16.
Elenore can use a string of length 5.
Elenore can use a string of length 22.
hint
source
Submit