#abc343g. G - Compress Strings
G - Compress Strings
Score: points
问题描述
给定 个字符串 。
找出包含所有这些字符串作为子串的最短长度的字符串。
这里,若一个字符串 通过删除任意数量的起始字符和任意数量的结束字符后能够得到字符串 ,则称字符串 包含字符串 作为子串。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given strings .
Find the minimum length of a string that contains all these strings as substrings.
Here, a string contains a string as a substring if can be obtained by deleting zero or more characters from the beginning and zero or more characters from the end of .
Constraints
- is an integer.
- is a string consisting of lowercase English letters whose length is at least .
- The total length of is at most .
Input
The input is given from Standard Input in the following format:
Output
Print the answer as an integer.
Sample Input 1
3
snuke
kensho
uk
Sample Output 1
9
The string snukensho
of length contains all of , , and as substrings.
Specifically, the first to fifth characters of snukensho
correspond to , the fourth to ninth correspond to , and the third to fourth correspond to .
No shorter string contains all of , , and as substrings. Thus, the answer is .
Sample Input 2
3
abc
abc
arc
Sample Output 2
6
Sample Input 3
6
cmcmrcc
rmrrrmr
mrccm
mmcr
rmmrmrcc
ccmcrcmcm
Sample Output 3
27
update @ 2024/3/10 01:17:08