Facebook Hacker Cup 2015 Round 2
This morning you woke up with an uncontrollable urge to send a text message made up of
Your plan is to just choose
What's the minimum number of letters you must type to send your message of
Input
Input begins with an integer
Output
For the Case #i:
followed by the minimum number of characters you need to type to send your text message.
Constraints
The
The words are made up of only lower-case alphabetic characters.
The words are pairwise distinct.
Explanation of Sample
In the first case, one option is to choose the words tin
, tinny
, gigantic
, and tilts
. You can then text these words by typing tin
, tinn
, g
, and til
, respectively, for a total of
Sample Input
5
6 4
tin
tiny
tinny
gigantic
tilt
tilts
3 2
apple
apricot
cherry
5 3
a
aa
aaa
aaaa
aaaaa
5 3
the
quick
brown
fox
jumped
8 7
cork
work
card
ward
font
front
word
sword
Sample Output
Case #1: 11
Case #2: 2
Case #3: 6
Case #4: 3
Case #5: 13
Comments