Facebook Hacker Cup 2015 Round 1
Since you crave state-of-the-art technology, you've just purchased a phone with a great new feature: autocomplete!
Your phone's version of autocomplete has some pros and cons. On the one hand, it's very cautious. It only autocompletes a word when it knows exactly what you're trying to write. On the other hand, you have to teach it every word you want to use.
You have
What's the minimum number of letters you must type to send all
Input
Input begins with an integer
Output
For the Case #i:
followed by the minimum number of characters you need to type in your text message.
Constraints
The
The words are made up of only lower-case alphabetic characters.
The words are pairwise distinct.
NOTE: The input file is about 10-20MB.
Explanation of Sample
In the first test case, you will write h
, he
, l
, hil
, hill
, for a total of
Sample Input
5
5
hi
hello
lol
hills
hill
5
a
aa
aaa
aaaa
aaaaa
5
aaaaa
aaaa
aaa
aa
a
6
to
be
or
not
two
bee
3
having
fun
yet
Sample Output
Case #1: 11
Case #2: 15
Case #3: 11
Case #4: 9
Case #5: 3
Comments
Shouldn't this problem be categorised as graph theory as well?
The problem can be solved using a string algorithm that is a graph too. I think string algorithm is better since it is more specific