QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB Total points: 100

#266. Generalized Suffix Automaton

Statistics

Given $n$ strings $s_1, s_2, \dots, s_n$ consisting of lowercase letters, find the number of distinct substrings. (Excluding the empty string.)

Input

The first line contains a positive integer $n$.

The following $n$ lines each contain a string, where the $i$-th line represents the string $s_i$.

Output

A single line containing a positive integer representing the answer.

Examples

Input 1

10
orzhy
hyakcts
hyakapio
hyakioi
hyaknoi
hyaknoip
bytheway
therulesforthenextseasonwillbeadjustedsoonsostaytuned
gpofuralswillbeheldonmaytheninethusualtimeuralchampionshiponsiteteamsresultswillbecounted
thewidesiberianolympiadchangedtherulesfortheselectioncontestfromacmtomixedacmmarathonwithvariablescoringsoitcannotbeusedastheopencupstageatthecurrentseasoninnextseasonsthenonacmscoringstagesmaybeconsideredbutmajorlastminutechangesarenotacceptablesothegrandprixofeurasiaatoctthetenthiscancelled

Output 1

47675

Subtasks

For all test cases, $1 \leq n \leq 10^5$ and $1 \leq \sum |S| \leq 10^6$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.