JZOJ5915 [2018NOIP Simulation] Rising Star (generalized suffix automaton, segment tree)

Title Description

Given a tree, each node has a weight value \ (a_i \) and a string \ (S_I \) .
q group query, each query string S and a two nodes x, y:
find the number of string x to y each node on the path appearing in S multiplied by the sum of the respective weights.
An operation to modify the weights of a single point.
$ n, q \ leq 200000, \ sum s_i, \ sum S \ leq 400000 $
by force, but not encrypted query string.

sol

First Orz fairy Jouna_Kasa_Hasinele
first consider the square of the level of practice, every time when asked to build a suffix automaton, traversing all nodes statistics as \ (s_i \) and appears on the <u, v> path multiplied by the string \ ( a_i \) sum.

This approach to get better, all query strings pretreatment generalized suffix automaton, and all \ (S_I \) and the corresponding information on the sub-string hanging node.
For doing a query string, only consider node associated with the string of statistics \ (\ SUM size_i \ Times a_i \) .
However, since there is located <u, v> restriction on the path, on the tree about the difference + Eulerian maintenance, it can be converted into four segments prefix and Euler sequence.
Maintenance for each suffix automaton node balanced trees / dynamic prescription segment tree, support modify \ (a_i \) and check prefix and can be.
Suffix tree above due to the complexity of the total number of points is a direct enumeration count size directly Fenwick tree can be maintained.

Time complexity \ (O ((Q + | S |) \ n-log) \) .

Guess you like

Origin www.cnblogs.com/bestwyj/p/11610249.html