2019 cattle off more school eight H. How Many Schemes (AC automata, tree chain split)

Effect: Given a tree, each side has a set of characters, a given pattern string $ m $, $ a $ query Q $ (u, v) $, the path $ (u, v) of all edges $, each side taken from the corresponding set of characters in a character string to obtain a $ s $, $ s $ required number of programs comprising at least a pattern string.

 

The AC $ $ automaton built, each point of a matrix maintains $ v_ {i, j} $, represents the AC $ $ $ automaton from state to several $ $ i $ J program.

Tree direct violence sectional complexity is $ O (nt ^ 3 + qt ^ 3log ^ 2n) $, pretreatment complexity OK, but the inquiry time is too large.

Multiplying each interrogation fact only a matrix state $ $ 0 value corresponding to that line, so only one vector per use $ n ^ 2 $ can be multiplied.

And because without modification operations may be first $ O (nt ^ 3) $ preconditioning matrix product to each point of the head of the chain, only when the last time the same query on one strand of the segment tree during this interrogation.

Therefore, the total complexity is $ O (nt ^ 3 + qt ^ 2logn) $ through.

Guess you like

Origin www.cnblogs.com/uid001/p/11415910.html