#P9089. 「SvR-2」Work
「SvR-2」Work
Problem Description
Given strings consisting of lowercase letters, define the value of the -th string as the number of its meaningful substrings (if there are multiple essentially identical substrings, they are also counted multiple times). A substring of the -th string is meaningful if and only if it can be split into several strings, where each part is a suffix of any of the strings.
Here is an example with :
int
printf
scanf
ntnt
-
For the string
printf, the substringintfis meaningful, because it can be represented asintandf, which are suffixes ofintandscanf, respectively. However,rintis not. -
For the string
ntnt, the substringntntis also meaningful, because it can be represented asntandnt(both are the same suffix ofint), or it can be represented asntnt, which is a suffix ofntnt.
Now, Little Z wants to know the sum of the values of these strings.
Input Format
The first line contains an integer .
Then follow lines, each containing a string.
Output Format
Output one integer in one line, representing the sum of the values.
4
int
printf
scanf
ntnt
23
4
ireallywanttobemissjiaransdog
butmissjiaransaidthatshelikedcatsandicried
iknowwhyicrywheniamneitheradognoracatbecauseimactuallyamouse
ineverexpectedmissjiarantolikeherselfiunderstandthatallpeopleliketounderstandthecutedogorcatthatyuyuusestomakemoneyandnoonelikesthemousewithwetandwetdiseases
391
Hint
Constraints
This problem uses bundled testdata and O2 optimization.
Let denote the length of the -th string.
| Subtask | Constraints / Special Properties | Score |
|---|---|---|
| , | ||
| , each string consists of only one character | ||
For of the testdata, , and .
Translated by ChatGPT 5