Well.. The past one months to dare to move a test of the problem it. After all, good God, good God.
Look right → it says Orz yu990601.
Well, let's start with the T3 he dropped.
I looked at Sam last night. It's probably kind of nice.
After all, last summer was still heard ... Although I didn't understand
But it's nice to see CLJ's speeches now, most of them can read.
Go straight to this question ... First, the tree has no more than 20 leaf nodes.
Then a very magical nature is that all the substrings will appear in a straight line on a tree rooted in a leaf node ...
That's not good for solving problems ... That is, it must be a suffix on the path of a node on the tree that is the root of the leaf.
Then Sam can knock it up ... Build a SAM for each node, but the same substring does not need to be processed at all
Because Sam is ignoring the same substring ...
The last statistic substring ...
Obviously the suffix automaton holds each suffix of the string, so the substring is all the prefixes of those suffixes
Set Fail[i] represents the prefix of the string is all complete statistics, to continue to statistics I
You just need to count the length of the red part.
[BZOJ3926] [ZJOI2015] Gods blessed Fantasy Township | suffix automata